i tried to create this url rule buts not working: i dont know why :(
orginal url
www.example.com/viewprofile.php?username=jhon
the desired friendly url is
www.example.com/user/jhon
this is my.htaccess code:
RewriteEngine On
RewriteRule ^username/([^/]*)$ /viewprofile.php?username=$1 [L]
thanks for helping!! :))
I found this tutorial where the author explain step by step how to do exactly what you are trying to do. See if it helps: http://www.emanueleferonato.com/2008/06/15/how-to-generate-friendly-urls-with-htaccess-part-2/
Related
until now I have always used htaccess to rewrite URLS in order to have non-SEF url to SEF urls.
Today I am facing a new challenge that honestly, beeing non confident in regular expression, I really don't know how to achieve.
I have a situation where a forum on a website of mine has been update in the following form:
previous link: www.domain.com/forum3/topic/name-of-topic/post/7548
new link: forum.domain.com/Topic-name-of-topic/
How do I intercept /post/37764 string and tell htaccess to not consider it?
And how to instruct the server to build that kind of url instead of the provious. I am very confused about it.
Any suggestion? Thank you very much. Is there any resource that I can read to help me better understand the case?
Thanks again.
EDIT
Florian answer is correct. I just added few mods to fit it better.
RewriteEngine On
#RewriteBase /
RewriteRule ^forum3/topic/([^/]+)/post/[0-9]+$ http://forum.domanin.com/Topic-$1/ [L,R=301]
RewriteRule ^forum3/topic/([^/]+)-[0-9]+$ http://forum.domanin.com/Topic-$1/ [L,R=301]
You can try this code :
RewriteEngine On
RewriteBase /
RewriteRule ^forum3/topic/([^/]+)/post/[0-9]+$ /Topic-$1/ [L,R=301]
/([^/]+)/ means that we want to catch a string containing one or more characters except / preceded and followed by a /.
This link might help you to test your .htaccess files :
Test your apache htaccess files online
I need help from experts to solve my problem. I'm just starting to learn rewriterule, rbase, and rcond. I want to rewrite my site link like codeigniter MVC. For example:
http://localhost/app/index.php?page=profile&user=john -> http://localhost/app/index/page/profile/user/john
How to do that? I tried to change for many times, but i don't get url like that but error occured.
RewriteRule ^index/page/(.*)/user/(.*)$ /index.php?page=$1&user=$2 [L]
I change my URL name using mod write. But my URL doesn't show the changes on browser.
This is how it looks from before and after
www.mydomain.com/toy/image.php
to this
www.mydomain.com/toy/xbox
How can I make this: www.mydomain.com/toy/xbox appear on the browser
Another words on my website it should appear www.mydomain.com/toy/xbox instead of this
www.mydomain.com/toy/image.php
This is my code:
RewriteEngine On
RewriteRule ^toy/xbox$ /toy/image.php* [L,R]
Can someone to explain to me how it works. Did I missed a step? Do I need to used PHP?
If I did make a mistake, correct me so I can learn from my mistakes. I try to google this but I couldn't find what I need to do
Any links or explanations would be appreciated. Thanks.
For it to "show the URL," you need it to do a 301/302 redirect, with a location header. All you have to do is end your RewriteRule line with [L,R=301]
You must perform a redirect using the R flag instead of just a rewrite.
RewriteRule ... ... [R]
I have a url like this
http://example.com/wp-login.php?action=logout&_wpnonce=ab720d18d2
Can someone help me to rewrite like this
http://example.com/logout/ab720d18d2
Thanks
We are here to answer question. Not to write code for you.
But because it is almost christmas:
RewriteRule ^logout/(.*) /wp-login.php?action=logout&_wpnonce=$1
I've a URL which get file name through get method and display it on the page.
tvchaska.info/i/
this is the page and when u click any image it will go to say
http://tvchaska.info/i/output.php?i=http://brothertattoo.co.uk/wp-content/uploads/2011/09/Sexy-Girl-Tattoo.jpg
I want my this URL to be rewritten as tvchaska.info/i/Sexy-Girl-Tattoo.html
I tried following rule but it is not working
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /output.php?i=$1 [L]
Can any one plz help me to attain this plz?
I've seen you page, I'll give you the answer only if I can meet 3 girls of your page IRL! Just kidding.
Here's the solution:
-1: all your link don't have to be like:
/i/output.php?i=http://1.bp.blogspot.com/_R2Wo1mDtuko/TGzOFQEhpoI/AAAAAAAACAA/Na-WQ1xe7dY/s1600/sexy.jpg
but something like:
/i/1.bp.blogspot.com/_R2Wo1mDtuko/TGzOFQEhpoI/AAAAAAAACAA/Na-WQ1xe7dY/s1600/sexy.jpg
-2: once you've modified your site, apply those rules:
RewriteEngine On
RewriteRule ^/i/(.*)+ /i/output.php?i=http://$1
This will do the job.
Olivier