Slay
Slay

Reputation: 1283

How to rewrite url to omit one parameter

I have the following url. I want to rewrite the following url to omit the "view" from the url.

Here is currently my existing mod rewrite

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?url=$1 [PT,L]

</IfModule>

http://example.com/page/view/helloworld

How do i rewrite the url to make it

http://example.com/page/helloworld

the keyword helloworld is dynamic.

Expert advice appreciated.

Upvotes: 0

Views: 42

Answers (1)

kheld
kheld

Reputation: 792

You might want to add the R=301 into the flags if you are worried about transfering SEO.

RewriteEngine On

RewriteRule ^(.+)/view/(.+)$ /$1/$2 [L]

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

Upvotes: 1

Related Questions