Hie guys, I've an issue with the mod_rewrite, is about remove the whole example.com/index.php?page='home' to example.com/page/home i tried but stil with no success but only the index.php is gone there is my .htaccess look like:
# Options +FollowSymLinks RewriteEngine On #
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?page=$1
RewriteRule ^(([^/]+/)*)index.php?$ http://localhost/hector/$1 [R=301,L]
#
Disclaimer: I am not good at .htaccess rules. I'm stumbling my way around here. But isn't this what you want, in a basic sort of way?
Options +FollowSymLinks RewriteEngine On RewriteRule ^page/(.*)$ http://localhost/hector/index.php?page=$0 [NC]
With this, if the user types in http://localhost/hector/page/cheeseburgers the page http://localhost/hector/index.php?page=cheeseburger is requested, but the user sees http://localhost/hector/page/cheeseburgers in their address bar. Still needs a regex to strip trailing slashes.
http://localhost/hector/page/cheeseburgers
http://localhost/hector/index.php?page=cheeseburger
From your example, it looks like you're reversing this, which would cause a 404 error, if I'm not mistaken? flounders
No my friend, the url is http://localhost/hector/index.php?page=Home after my .htaccess it removed the index.php and becomes this: http://localhost/hector/?page=Home the links work fine but what i want was to become this link without the question mark and = llike this: http://localhost/hector/page/Home
Aha! We were both considerably off. It's the QUERY_STRING that should be referenced, not REQUEST_FILENAME. This should do the trick:
QUERY_STRING
REQUEST_FILENAME
Options +FollowSymLinks RewriteEngine On RewriteCond %{QUERY_STRING} ^(\w+)=(\w+)$ RewriteRule ^([a-z]+)/(index\.php) $1/%1/%2? [R=301,L]
Here are a couple of good resources for testing .htaccess rules: http://htaccess.madewithlove.be/ (doesn't support %{REQUEST_FILENAME}) and: http://martinmelin.se/rewrite-rule-tester/
%{REQUEST_FILENAME}
thank you for your help but it doesn't work still the same
Hie guys, I've an issue with the mod_rewrite, is about remove the whole example.com/index.php?page='home' to example.com/page/home i tried but stil with no success but only the index.php is gone there is my .htaccess look like:
# Options +FollowSymLinks RewriteEngine On #
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?page=$1
RewriteRule ^(([^/]+/)*)index.php?$ http://localhost/hector/$1 [R=301,L]
#
Disclaimer: I am not good at .htaccess rules. I'm stumbling my way around here. But isn't this what you want, in a basic sort of way?
With this, if the user types in
http://localhost/hector/page/cheeseburgersthe pagehttp://localhost/hector/index.php?page=cheeseburgeris requested, but the user seeshttp://localhost/hector/page/cheeseburgersin their address bar. Still needs a regex to strip trailing slashes.From your example, it looks like you're reversing this, which would cause a 404 error, if I'm not mistaken? flounders
No my friend, the url is http://localhost/hector/index.php?page=Home after my .htaccess it removed the index.php and becomes this: http://localhost/hector/?page=Home the links work fine but what i want was to become this link without the question mark and = llike this: http://localhost/hector/page/Home
Aha! We were both considerably off. It's the
QUERY_STRINGthat should be referenced, notREQUEST_FILENAME. This should do the trick:Here are a couple of good resources for testing .htaccess rules: http://htaccess.madewithlove.be/ (doesn't support
%{REQUEST_FILENAME}) and: http://martinmelin.se/rewrite-rule-tester/thank you for your help but it doesn't work still the same