简体   繁体   中英

.htaccess redirect subdirectory to subdirectory

I want to redirect the URL http://example.com/sub-folder/filename.html to http://example.com/sub-folder/index.php?p=filename.html

I already have the following:

    <IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /
    #RewriteRule ^stedentrip-naar/([a-zA-Z0-9_-]+)\.html$  stedentrip-naar/index.php?p=$1 [L,NC,QSA]
    RewriteRule ^stedentrip-naar/(.*)$ /stedentrip-naar/$1 [R=301,NC,L]
    </IfModule>

Place this rule in your /sub-folder/.htaccess :

RewriteEngine on
RewriteBase /stedentrip-naar/

RewriteRule ^([\w-]+\.html)$ index.php?p=$1 [L,QSA,NC]

Try this:

RewriteEngine on 
RewriteRule ^sub-folder/([a-zA-Z0-9_-]+)\.html$ sub-folder/index.php?p=$1.html

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