Tom
Tom

Reputation: 596

How can I make multiple permalinks in .htaccess?

The problem is that I have a .htaccess file which redirects users that go to example.com/f89sk3 -> example.com/?s=f89sk3 if it makes any sense.

I want the same thing to happen for people that go to for example: example.com/p/login -> example.com/p/login

This is my current .htaccess file:

RewriteEngine On

RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

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

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

Upvotes: 1

Views: 72

Answers (1)

anubhava
anubhava

Reputation: 786091

You can use these rules:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteRule ^p/(.+)$ index.php?p=$1 [QSA,L]

RewriteRule ^(.+)$ index.php?s=$1 [QSA,L]

Upvotes: 1

Related Questions