0

I know that apache .htaccess files are capable of rewriting URLs and making them more readable and efficient, but I don't know how to achieve this.

Lets say I have these kinds of URLs:

http://mywebsite.com/index.php?mode=home
http://mywebsite.com/index.php?mode=articles
http://mywebsite.com/index.php?mode=about

But I want these to look nicer and readable. Something like this:

http://mywebsite.com/home
http://mywebsite.com/articles
http://mywebsite.com/about

This seems like a complex task for an apache novice like myself.

I'd appreciate any help.

1
  • 2
    duplicate of so many other questions, it hurts to check Commented Dec 3, 2013 at 19:22

1 Answer 1

2

Place this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/?$ index.php?mode=$1 [QSA,L]

Reference: Apache mod_rewrite Introduction

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.