Reputation: 51
I am making my own CMS for my social networking website. I'm facing a problem, I need to clean the url to make it pretty like facebook does.
URL Rewrite using HTACCESS
Urgly URL => www.domain.com/index.php?options=profile&id=393
Clean URL => www.domain.com/393
Currently am using this code below to remove inde.php?options from url
RewriteCond %{REQUEST_FILENAME} !index.php
RewriteRule .* index.php?options=$0 [QSA,L]
I have searched Google and tired everything but it does not work for me. Something is weird...
please help am stuck really badly..!
Upvotes: 1
Views: 404
Reputation: 4976
I suppose your rule+condition will match every request including images, scripts, stylesheets etc and will redirect it to index.php. I doubt that's what you want.
You can rather do it the other way around. If people visit your index.php or top domain name (eg. www.domain.com) do nothing.
RewriteRule ^index\.php$ - [L]
Then you can rewrite all applicable requests (paths that doesn't exist) to index.php.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php?options=$0 [L,QSA]
Add these rules+conditions to your .htaccess and see if it meets your requirements.
Upvotes: 1