Mobile app version of vmapp.org
Login or Join
Moriarity557

: Apache .htaccess URL rewriting is not working I am using this code in .htaccess but the last line not giving any response: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond

@Moriarity557

Posted in: #Apache #Htaccess

I am using this code in .htaccess but the last line not giving any response:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ user_pro.php?id= [QSA,L]
RewriteRule ^(.*)$/images image.php?id= [QSA,L] #this line not giving any response

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Moriarity557

2 Comments

Sorted by latest first Latest Oldest Best

 

@Moriarity557

the $ anchor signals the end of the subject (as ^ signals the start), thus your expr is incorrect.

What you're lookng for is more likely something like

# to rewrite images/foo to image.php?id=foo
RewriteRule ^images/(.*)$ image.php?id= [QSA,L]

# to rewrite foo/images to image.php?id=foo
RewriteRule ^(.*)/images$ image.php?id= [QSA,L]


For more info have a look at mod_rewrite intro and the mod_rewrite documentation

10% popularity Vote Up Vote Down


 

@Megan663

First, make sure mod_rewrite is on:
*https://httpd.apache.org/docs/current/mod/mod_rewrite.html*


If you're on a linux machine like Centos, you can check by running
httpd -l to list compiled (installed) modules. stackoverflow.com/questions/7337724/how-to-check-whether-mod-rewrite-is-enable-on-server

Lastly, are you including RewriteEngine on at the beginning of your code?

Try :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ user_pro.php?id= [QSA,L]
RewriteRule ^(.*)$/images image.php?id= [QSA,L]


I'm not really familiar with the syntax, so I can't tell you whether ^(.*)$/images image.php?id= [QSA,L] is proper or not.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme