I am Required to write rule for redirection in my website.and i am using codeigniter.so it will use index.php for all pages. So my first rule i used is
RewriteRule ^(.*)$ /index.php/$1 [L]
.
now i want to add some thing more which are follows.
My requirement first:
input - example.com/index.php/search/query
url to be redirected - example.com/search?q=query
And,
input - example.com/index.php/search/query&c=abc&s=xyz&p=1
url to be redirected - example.com/search?q=query&c=abc&s=xyz&p=1
Thats it.
Can Anyone crack code for this.? Please...
Thanks in Advance.
Edited: Tell some reference website to know more about rules and condition syntax to write .htaccess file.
In you html code you must write like this:
<a href='http://www.domain.com/index/211/title-goes-here'>url_text</a>
and in the htaccess file adapt the following:
Options +SymLinksIfOwnerMatch
RewriteEngine on
RewriteRule ^([a-zA-Z-]+)$ index.php?action=$1 [NC,L]
RewriteRule ^(member)-([0-9-]+)$ index.php?action=member&id=$2 [NC,L]
RewriteRule ^([a-zA-Z-]+)/([a-zA-Z-]+)-([0-9-]+)$ index.php?action=$1&saction=$2&sid=$3 [NC,L]
RewriteRule ^([a-zA-Z-]+)/([0-9-]+)$ index.php?action=$1&id=$2 [NC,L]
RewriteRule ^([0-9-]+)/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/(.*).html$ index.php?action=details&id=$1&p1=$2&p2=$3&p3=$4 [NC,L]
using () you mark the data that you need to extract and work with it;
using $x, where x=1,2,3, ...
$x is the value
the more () you have, the more $x you have
with: RewriteRule ^(member)-([0-9-]+)$ index.php?action=member&id=$2 [NC,L]
(member) is $1 and ([0-9]+) is $2
do you understand?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.