I have a url like : www.mysite.com/truck/user/?l=2&lang=en&online=450215437
i want to rewrite like : www.mysite.com/truck/?l=2&lang=en&online=450215437
Mean i dont want user folder apear on url .
I have try this in .htaccess file but not work :
RewriteEngine on
RewriteRule ^(user\/\?l=([0-9]*)&lang=(.*?)&online=([0-9]*))$ index.php?l=$1&lang=$2&online=$3 [L]
Please help me :s
That rule is wrong since RewriteRule doesn't match QUERY_STRING. Use this rule instead:
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(truck/)user/?$ $1 [L,NC]
QUERY_STRING will be carried over automatically.
Related
I've got an address like this:
/?pid=74&sid=381:naprawairegeneracjaturbosprezarek24hjozefkrezolek
and i want to have:
/74:381:naprawairegeneracjaturbosprezarek24hjozefkrezolek
or better:
/naprawairegeneracjaturbosprezarek24hjozefkrezolek
my .htaccess
Options -Multiviews
RewriteEngine On
RewriteBase /
RewriteRule ^([a-z]+):([a-z]+):([a-z]+)$ /index.php?pid=$1&sid=$2:$3 [L]
I have also rewrite rule to delete index.php from url
RewriteRule ^([0-9]+):([0-9]+):([a-z]+)$ /index.php?pid=$1&sid=$2:$3 [L]
You cannot achieve /naprawairegeneracjaturbosprezarek24hjozefkrezolek unless you make sure that index.php can find the correct item with only that parameter.
RewriteRule new/$ /search.php?category=1
RewriteRule new/\?(.+)$ /search.php?category=1&$1
I'm trying to do something like this, if the following address link is accessed,
http://onlineshop.com/new/
http://onlineshop.com/new/?price_max=30
then it will open this link,
http://onlineshop.com/new/search.php?category=1
http://onlineshop.com/new/search.php?category=1&price_max=30
Unfortunately it is not working this way.
A RewriteRule won't naturally catch query string parameters, you must use this kind of .htaccess :
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^new/$ /search.php?category=1&%1
You can just simply redirect from /new to /search.php with QSA flag and Apache will append the existing query string. Something like this will work for you:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^new/?$ /search.php?category=1 [L,QSA,NC]
Hi i make one cms sites and i need to rewrite my url
current my url is http://www.example.com/index.php?link=pages&cmsid=2&cmsLink=Carpet
it refers the cmsLink
I want my url like http://www.example.com/Carpet
I am using the following code
Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteBase /
RewriteRule ^index.php?link=(.*)&cmsid=(.*)&cmsLink=(.*) $3
To achive this url it not directly possible with .htaccess
I use regular expression and other tings in htacess as well
I put remove the cmsid
current my url is http://www.example.com/index.php?link=pages&cmsLink=Carpet
RewriteCond %{REQUEST_URI} !/admin
RewriteCond %{REQUEST_URI} !^/(.*).php
RewriteBase /
RewriteRule ^([^/]+)/?$ index.php?link=pages&cmsLink=$1&%{QUERY_STRING} [L]
it return me http://www.example.com/Carpet
Try changing your last rule to this:
RewriteRule ^(.+)$ /index.php?link=pages&cmsid=2&cmsLink=$1
Since you want to have url like http://www.example.com/Carpet, so cmsid and link in your url has to be hardcoded to 2 and pages.
Lets say I have a two websites www.sample.com and files.sample.com.
In an .htaccess file within the webroot of www.sample.com, I have the following:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{QUERY_STRING} ^files\/uploads [NC]
RewriteRule ^(.*)$ http://files.website.com/$1 [NC,L]
</IfModule>
The desired result is to have all requests of www.sample.com/files/uploads/file.xml or www.sample.com/files/uploads/subfolder/file.json get 302 redirected to files.sample.com/files/uploads/file.xml and www.sample.com/files/uploads/subfolder/file.json, respectively.
However, I can't get the rule to fire. The directory "files" does not exist on the www.sample.com website at all.
Could anyone give me a little help as to why the
You probably want REQUEST_URI not QUERY_STRING.
RewriteCond %{REQUEST_URI} ^/files\/uploads [NC]
Also note the leading slash.
Did you turn on mod_rewrite in your apache config?
Also yor change '^files/uploads' to ^/files/uploads and QUERY_STRING to PATH_INFO.
QUERY_STRING - this is all data after '?' character.
I'm trying to set up a rewrite that will redirect this URL:
/video-2011.php?video=150
to this:
/video/150/freeform-title-text-here/
I have the rewrite working using this line in my HTACCESS:
RewriteRule ^video/([0-9]+)/(.*)$ video-2011.php?video=$1 [L]
But as soon I add R=301 into the mix, it breaks. Any ideas?
Here's the full HTACCESS when it breaks:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^video/([0-9]+)/(.*)$ video-2011.php?video=$1 [R=301,L]
Any help is greatly appreciated, thanks!
I think you might be missing a line from your .Htaccess.
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^video/([0-9]+)/([a-z0-9-_]+)$ video-2011.php?video=$1 [L]
#New
RewriteCond %{REQUEST_URI} !^/video/([0-9]+)/([a-z0-9-_]+)/?$
RewriteCond %{QUERY_STRING} ^video=([0-9]+)&name=([a-z0-9-_]+)/?$
RewriteRule ^video-2011.php$ video/%1/%2/? [R=301,L]
I assuming you want to rewrite the url if it is:
/video/150/freeform-title-text-here/
And redirect the url if it is:
/video-2011.php?video=150
to:
/video/150/freeform-title-text-here/
So this way it keeps the urls looking pretty and tidy.
Please correct me if I am wrong.
Edit
I've added in a RewriteCond to stop the second rewrite happening.
As the first rule will obviously rewrite:
/video/150/freeform-title-text-here/
Which means the query string you don't see:
/video-2011.php?video=150
Would of made the second rule happen too.
Can you try:
RewriteRule ^video/([0-9]+)/ /video-2011.php?video=$1 [R=301,L,NC,QSA]
And yes it will redirect /video/150/foo to /video.php?video=150 not the other way around as you've stated in your question.