SuperNinja
SuperNinja

Reputation: 1606

.htaccess RewriteRule, remove URL Segment

I am trying to remove 'beta' from my url via .htacess. Tried several different iterations with no luck. Here is my current .htaccess.

Update: My URL is http://pfdev.domainname.dev/beta/galleries.

My current rewrite below, works like I want it as it's removing index.php from http://pfdev.domainname.dev/beta/index.php/galleries. I have found several questions answered regarding the same issue, but applying them here hasn't worked for me yet.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /beta/index.php?$1 [L]

Any help appreciated. Thanks

Upvotes: 0

Views: 1116

Answers (1)

anubhava
anubhava

Reputation: 786339

You can have a redirect rule to remove /beta/ from URLs:

RewriteEngine on
RewriteBase /

RewriteCond %{THE_REQUEST} /beta/(\S*)\s [NC]
RewriteRule ^ %1 [L,R,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!beta/).*)$ beta/index.php?$1 [L,QSA]

Upvotes: 3

Related Questions