I am sick of this kind of URL:
www.domain.com/something/?id=person&photos=photoID&variable1=others&...
I am using apache, learning to write .htaccess now. Can anyone show me the basic code for this one?
Ugly:
www.domain.com/something/?id=person&photos=photoID
Goal:
www.domain.com/something/person/photoID
RewriteEngine on
RewriteRule ^something/(.*)/(.*)$ something/?id=$1&photos=$2 [QSA]
This is an extremely helpful article on Mod_Rewrite
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
Hi I'm not that great at regex and have been tasked with cleaning up a line by line .htaccess file. I've read that RewriteMap is a good alternative to avoid a messy .htaccess file, but I've really got no idea where to start. Most guides seem to require prerequisite knowledge that I do not have. Can anyone help me?
I use ISAPI Rewrite III for Windows IIS, so it may not be exactly the same as php, but if not at least its very close. This is what I use:
RewriteEngine on
RewriteBase /
RewriteMap artMap txt:d:/inetpub/pathToMapDirectory/artMap.txt [NC]
RewriteRule ^Frequency-Machine/(.*) ${artMap:$1} [NC]
"Frequency-Machine" can be any text string that you want to use to trigger the rewrite map operation. I use a different string for each site that I do.
Here is a sample of the map file:
The-Analog-vs.-Digital-Frequency-Debate content1.asp?id=47&catID=1
The-GB4000-Frequency-Generator content1.asp?id=12&catID=1
Video-Tutorial-Flash content1.asp?id=58&catID=1
GB400-Frequently-Asked-Questions content1.asp?id=49&catID=3
Hope that helps.
I need to rewrite a url for specific component in joomla so that actual component name is not visible in url .
E.g index.php?option=com_mycomponent
I need to replace com_mycomponent to xyz
Also I installed joomsef extension but it does not work fine with language filter plugin in joomla.
So I need to rewrite a url for specific component using htaccess
So please suggest me appropriate solution asap
The "Simple Custom Router" extension may be able to help you:
http://extensions.joomla.org/extensions/site-management/sef/21251
Hopefully this is ASAP enough for you. :)
Have you tried a basic .htaccess rewrite? Shouldn't be too tough with basic rewrite engine:
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^my_component_pretty_url$ ?option=com_mycomponent [NC,L]
If anyone has better rewrite rules, please add...mine are super basic.
Try this,
RewriteEngine On
RewriteRule ^chaletreservation$ index.php?option=com_jrestaurantreservation [QSA,L]
RewriteRule ^chaletreservation(.+)$ index.php?option=com_jrestaurantreservation&$1 [QSA,L]
Then simply use where ever you need this component urls index.php?option=com_jrestaurantreservation like below,
www.yourdomain.com/chaletreservation
Hope its works..
I have the following URL: http://sitename.com/?parameter_1=data¶meter_2=data
it always remains the same with the same data. I want it to be converted into the following URL: http://sitename.com/most-popular
I believe it is quite simple to do it from .htaccess but I am not familiar with rewrite rules.
Thank you.
If I correctly understand what you mean, you could try this
RewriteRule ^most-popular/?$ ?parameter_1=data¶meter_2=data [L]
I've been trying to create a rule.
If anyone could help, I would be extremely grateful.
Request: domain.com/c/wb.php?p=rs/rs/1tb/25n/ru/rs
Rewrite to: domain.com/c/wb/rs/rs/1tb/25n/ru/rs
Thanks in Advance
I think you have this a bit backwards. The idea behind URL rewriting is that you take a nice neat URL like this (what the user sees):
http://domain.com/c/wb/rs/rs/1tb/25n/ru/rs
and rewrite it behind the scenes into an uglier but PHP etc. friendlier URL like this (what the server processes):
http://domain.com/c/wb.php?p=rs/rs/1tb/25n/ru/rs
To do that, use this:
RewriteEngine On
RewriteRule ^/c/wb/(.*) http://domain.com/c/wb.php?p=$1 [L, NS]
It should look something like this
RewriteRule ^(c/wb)\.php\?p=(rs/rs/1tb/25n/ru/rs)$ $1/$2 [L,NS]
Still I'm not sure if you need slash in front of c/wb if you're using this in your .htaccess file. You need slash if you're using this in the VirtualHost configuration.