paranjothi
paranjothi

Reputation: 1

htaccess rewrite clean url for multiple parameters

This is my .htaccess code for clean url rewriting.

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^[a-zA-Z]{3,}\s/+index\.php\?bank=([^\s&]+) [NC]
RewriteRule ^ %1%2%3%4? [R=301,L]
RewriteRule ^([^/]+)/?$ index.php?bank=$1$2$3$4 [L,QSA]

This code works fine for single parameter in url. For example it rewrites

http://example.com/example-path/ to
http://example.com/index.php?bank=example-path/

But when I tried to pass multiple parameters in url, all I got are errors.

I need a url like
http://example.com/example-path instead of http://example.com/index.php?bank=example-path

How can I alter My code to pass multiple urls.

Upvotes: 0

Views: 363

Answers (1)

Ultimater
Ultimater

Reputation: 4738

Your redirect logic can be greatly simplified to just:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

#If a request does not match an existing directory
  RewriteCond %{REQUEST_FILENAME} !-d
#And does not match an existing file
  RewriteCond %{REQUEST_FILENAME} !-f
#then rewrite all requests to index.php
  RewriteRule ^(.*)/?$ index.php?bank=$1 [L,QSA]

Upvotes: 2

Related Questions