I want to use htaccess rewrite, which will act as below
1. http://mysite.com/?sura=x as http://mysite.com/x
2. http://mysite.com/?sura=x as http://mysite.com/x/
3. http://mysite.com/?sura=x&ayat=y as http://mysite.com/x/y
4. http://mysite.com/?sura=x&ayat=y as http://mysite.com/x/y/
is it possible by htaccess ??
please help me

Recommended Answers

All 5 Replies

thanks pixelsoul

RewriteEngine On
RewriteRule ^([^/]*)$ /?sura=$1 [L]
RewriteRule ^([^/]*)/$ /?sura=$1 [L]
RewriteRule ^([^/]*)/([^/]*)$ /?sura=$1&ayat=$2 [L]
RewriteRule ^([^/]*)/([^/]*)/$ /?sura=$1&ayat=$2 [L]

This is not working

but only this works

    RewriteRule ^([^/]*)/([^/]*)$ /?sura=$1&ayat=$2 [L]
    RewriteRule ^([^/]*)/([^/]*)/$ /?sura=$1&ayat=$2 [L]

try this:

RewriteRule ^([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)$ /?sura=$1&ayat=$2 [L]
RewriteRule ^([a-zA-Z0-9-]+)$ /?sura=$1 [L]

they must be in this order, in case there is only 1 param, the second rule will be 'executed'. also you may want to limit the type of characters that params can take.

commented: thanks +2

can you be more specific and give a real example?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.