简体   繁体   中英

URL Rewrite in htaccess not working

i have a url www.example.com/mybooks/list.php?id=novel-15 now i want to rewrite this url as www.example.com/mybooks/novel-15 for this i have the following code in .htaccess file

<Files ~ "\.log$">
    Order allow,deny
    Deny from all
</Files>

RewriteEngine on
RewriteRule ^mybooks/([A-Za-z0-9-]+)/?$ mybooks/list.php?id=?id=$1 [NC,L]

but this is not working. anybody give me a good solution...

Try this rule in your /mybooks/.htaccess :

RewriteEngine on
RewriteBase /mybooks/ 

RewriteCond %{THE_REQUEST} /list\.php\?id=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-]+)/?$ list.php?id=$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