From : www.example.com/cut/456
To : www.example.com/cut/index.php?tag=456
I try this and it doesn't work
RewriteEngine On
RewriteRule ^([^/]*)$ /cut/index.php?tag=$1 [L]
From : www.example.com/cut/456
To : www.example.com/cut/index.php?tag=456
I try this and it doesn't work
RewriteEngine On
RewriteRule ^([^/]*)$ /cut/index.php?tag=$1 [L]
unless your .htaccess
located in cut
directory, it should be better to use:
RewriteRule ^cut/(.+)/?$ /cut/index.php?tag=$1 [L]
otherwise
RewriteRule ^(.+)/?$ index.php?tag=$1 [L]
should do. It seems to be the issue with your substitution string, it's hard to say what exactly is the cause since doesn't work is not a sufficient description of a problem.
If you just expect integer values, you should restrict your pattern to such values:
RewriteRule ^([1-9][0-9]*)$ index.php?tag=$1 [L]
The problem with your current pattern is that ^([^/]*)$
does also match index.php
(/cut/index.php
without the per-directory path prefix) and thus may cause an infinite loop.
Is the server actually loading .htaccess? You can check this by chucking garbage at the end of the file and seeing if you get an error for it.
If it's not, AllowOverride
is probably set to None somewhere higher in the directory tree. Try declaring a <Directory /path/to/cut>
somewhere in your Apache's main configuration file and putting AllowOverride All
in it.
RewriteEngine On
RewriteBase /cut/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)$ /index.php?tag=$1 [L]
It's work with this