My url is ..../blogs?id=1&title=news
Now i need to covert this to
..../blogs/1/news
in .htaccess.
Please how to convert this. help me.
Use these lines:
RewriteEngine on
RewriteRule ^blogs/(.+)/(.+)$ /blogs.php?id=$1&title=$2 [R,L,QSA]
Related
I am trying to redirect a pattern of urls
http://style.com/style-blog/entry/what-im-looking-for-in-my-next-15-inch-laptop
to
http://style.com/blog/entry/what-im-looking-for-in-my-next-15-inch-laptop
I have tried to match the "style-blog" here
^style-blog/([A-Za-z0-9-]+)$ or ^style-blog/$
I needed to the first version to get ANY remaining part of the url to append to the new url here
RewriteRule ^style-blog/([A-Za-z0-9-]+)$ http://style.com/you-blog/$1 [NC,L]
Thanks for pointers on what I am doing wrong.
I think you may just be missing a /:
RewriteRule ^/style-(blog/[A-Za-z0-9-]+)$ http://style-review.com/$2
Using wildcard:
RewriteRule ^/style-(blog/.*)$ http://style-review.com/$2
Do you even need the full URL?
RewriteRule ^/style-(blog/.*)$ /$2
Are the ^ and $ required? Wouldn't just this work?
RewriteRule style-blog/ blog/
RewriteRule ^style-blog/(.*)/(.*)$ http://%{HTTP_HOST}/you-blog/$1/$2 [R=301,L]
This appears to be working but thanks to you guys you got me on the right track and probably you didn't have enough information to solve it. Its not fully tested yet and might not cope with any extra 'folders' (bits between slashes)
I am tring to accomplish simple task using mod-rewrite
I need url of such kind
http://localhost/docs/path/to/a/file/somefile_without_extension?d=file.txt
became downloadable so user will download a file with name file.txt as attachment
I use something like this trying to make it working but it not. Please note
somefile_without_extension
is normal image for example
RewriteEngine On
RewriteRule ^/ ?d={d}
Header set Content-disposition "attachment; filename=%{d}e" env=d
Try this:
RewriteCond %{QUERY_STRING} ^(.*)[\&|\?]*d=([\w|\d|\.|\%|]*)[\&]*(.*)$
RewriteRule .* - [E=FILENAME:%2]
Header set "Content-disposition" "attachment; filename=%{FILENAME}e" env=FILENAME
UnsetEnv FILENAME
I need to redirect a URL to another URL. So far I have done this in the .htaccess:
Redirect 301 http://domain.com/mypage.php http://newdomain.com/mynewpage
This works fine, but it copies the GET variables in the new URL as well. So I end up with
http://domain.com/mypage.php?item=32
being redirected to:
http://newdomain.com/mynewpage?item=32
I want remove all the variables in the new ULR. I know that this has to be done somehow with mod_rewrite, but I am struggling a lot with it and can not make it work.
Any help is appreciated.
Thanks
Ok,I got it myself... here is what I have done:
RewriteEngine On
RewriteCond %{QUERY_STRING} (.*)
RewriteRule (.*) %{REQUEST_URI}?
I have a URL:
"http://www.lootza.com/Model/Public/BuyNow/buynow.php?str=NDA="
I want to re-write this url as below:
"http://www.lootza.com/buynow/NDA="
I tried to do this by writing this below code in .htaccess but not getting any luck.
RewriteEngine on
RewriteRule ^$ /Model/Public/Home/
RewriteRule ^buynow/([0-9]+)/?$ Model/Public/BuyNow/buynow.php?str=$1
Please give me write syntax.
Regards
That seems correct assuming NDA= is an numeric string.
You can use the following to speed up your future test cycles:
http://civilolydnad.se/projects/rewriterule/
I need a help, does anyone can tell me how to change a url
"http://www.domain.com/search.php?key=+Ebooks&type=title&Submit=Search"
to
"http://www.domain.com/keyword- keyword- keyword.html".
i have written following htaccess code but its not working.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule search-(.*)-(.*)-(.*)\.html search.php?key=$1&type=$2&page=$3
</IfModule>
What exactly does not work? Is anything happening?
I am not 100% sure but I think you have to do it this way:
search-(.*?)-(.*?)-(.*?)\.html search.php?key=$1&type=$2&page=$3
Notice the ? behind the asterisks. It indicates to match a string as early as possible.
Try this:
RewriteRule search-([^-]*)-([^-]*)-([^-]*)\.html search.php?key=$1&type=$2&page=$3