简体   繁体   中英

htaccess RewriteRule and RewriteBase

i want hide a part of url current url: https://dev.karmagroup.com/karmamomentsnew/karma-postcards/

what i aim for is https://dev.karmagroup.com/karma-postcards/

with the current .htaccess file :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /karmamomentsnew/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /karmamomentsnew/index.php [L]
</IfModule>

i tried to change the .htaccess like this

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /karmamomentsnew/(.+)$ $1 [L,NC,R]
</IfModule>

and it goes wrong surely, haha.. can somebody help me please. thank you before.

I've found this related question which answers your problem. The snippet from the answer is (note that it's adjusted to your needs)

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (?!^karmamomentsnew/)^(.*)$ /karmamomentsnew/$1 [L,NC]

Source: https://stackoverflow.com/a/18361995/5675325

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