Home > Software design >  url given by RewriteRule with variable request "file" in url instead of file in RewriteRul
url given by RewriteRule with variable request "file" in url instead of file in RewriteRul

Time:12-28

To be honest I'm new to htaccess and my problem is when I want to access a link, while using htaccess rewriterule with a variable, it gives me a 404 error, since it wants to access to the variable as the file instead of the given one in the htaccess:

link looks like this: example.com/folder/variable

in the htaccess it looks like this:

RewriteEngine on
Options -Indexes -MultiViews
Order Allow,Deny
Allow from all
Satisfy any
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^folder/([0-9a-z-A-Z-_] )/$ folder/file.php?title=$1 [NC,QSA,L]

In theory it should work, as it work, but for me it doesn't. I tried to rewrite this code a "few" times, used lots of working codes for others to make mine working without any luck. In my httdp.conf file I changed AllowOverride None to AllowOverride All, I also checked if rewrite_module is active, and it is and it's working perfectly without variable. Also have a htaccess file with Satisfy any code in my folder.

I hope I (we) can troubleshoot this error in my code. Thanks for your future help and for your time!

CodePudding user response:

Found the mistake, here's the correct line ( / before $ made it not working):

RewriteRule ^folder/([0-9a-z-A-Z-_] )$ folder/file.php?title=$1 [NC,QSA,L]
  • Related