简体   繁体   中英

.htaccess getting wrong giving 500 internal error

I want to convert my link like this:

from http://example.com/pictures.php?title=new to http://example.com/new .

Here is my .htaccess ; it's giving me a 500 internal server error.

<IfModule mod_rewrite.c>
RewriteEngine On 
RewriteBase /
RewriteEngine On
RewriteRule ^([^/]*)$ /pictures.php?title=$1 [L]

</IfModule>
<IfModule mod_security.c> 
   # Turn off mod_security filtering. 
   SecFilterEngine Off 

   # The below probably isn't needed, 
   # but better safe than sorry. 
   SecFilterScanPOST Off 
</IfModule>

What's wrong in it?

I suspect your rewrite may be causing a loop. A RewriteCond to avoid a loop is usually a good idea;

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !=/pictures.php
RewriteRule ^([^/]*)$ /pictures.php?title=$1 [L]

you can try like this simply

RewriteEngine On
RewriteRule ^([^/]*)$ /pictures.php?title=$1 [L]

You should avoid rewrtiing actual files like .js, .css and images to pictures.php . Try this rule:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /pictures.php?title=$1 [L,QSA]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM