I need to do this:
I have an old URL:
http://www.mysite.com/dev-site/some-content-part-here
That I want to make into:
http://www.mysite.com/live/some-content-part-here
Edit
I found somebody voted down on my question. I dont know what thought drove him/her to that but actually the question really was not that silly! May be the downer did not understand why I asked this... it could be anything in his mind. But I want all readers, if you dont like question - please always try to communicate through comments and then if the question poster does not agree your changes, then down vote. Thanks.
*And guys, thanks for editing.
Untested:
RewriteEngine On
RewriteRule ^/dev-site/(.*)$ http://www.mysite.com/live/$1 [R=301,L]
Note that it might work if you only use /live/$1 on the right hand side, but I'd do this to be sure.
I know you know this (since you've mentioned mod_rewrite), but for those that don't, you generally put this into the .htaccess file in the directory - either dev-site or root should work.
Related
Gang,
Long time sysadmin but first time poster to this excellent site, so, please be gentle.
I am not strong at REGEX yet and trying to do two things at once on our internally hosted "mediawiki" site.
We are running an otherwise pretty plain jane LAMP stack (centOS 5.x, Apache 2.x, PHP 5.x). We are root. We are using /etc/httpd/conf.d/wiki.conf and not using .htaccess. The physical path is /var/www/html/wiki/
I have partially successful results with some combination of the below, but I am not good enough to get it all the way there. I know that there are some mod_write studs on this site that I am hoping to avail.
I am following this recipe https://www.mediawiki.org/wiki/Manual:Short_URL/Apache so as to shorten URL's from www.example.com/wiki/index.php?=title=Garden_Store to www.example.com/wiki/Garden_Store
still allow the use of www.example.com/wiki/index.php?=title=Garden_Store should the user should choose to type out that syntax of URL. (I believe that is possible with mediawiki to use both style URL's at the same time. If it is impossible, then I will be forced to skip the short URL and use the style with the variable in it.)
Last, string special characters from the URL in the example like www.example.com/wiki/index.php?=title=Garden,_Store! ought to be this www.example.com/wiki/index.php?=title=Garden_Store .
Another example of that might be www.example.com/wiki/index.php?=title=Garden_Store,_Inc. ought to be www.example.com/wiki/index.php?=title=Garden_Store_Inc
One last example, us to make sure that I am communicating well, would be getting this "/title=Garden%20Store,%20Inc" but wanting this "/index.php?title=Garden%20Store%20Inc" as I know that the spaces are replaced with underscores inside of mediawiki.
Thanks so much for walking a newbie the last bit to the finish line on this one.
Cheers.
Jason
Something like the following rules should do what you need:
RewriteRule ^(.*)\ (.*)$ $1\_$2 [L]
RewriteRule ^(.*)[^a-zA-Z0-9\/\._](.*)$ $1$2 [L]
First rule does replace space with underscore and the other line strips all chars you don't want to stay in the resulting URL. Note, your will probably need to add some more, if you want.
I've seen many cases of these rewrite questions but I don't get all the regular experessions and browser errors and such so I was hoping that someone could help me.
Ok, so I have a file with a url variable 'pages.php?p=foo' and I would like to rewrite it so that it appears as 'foo.html' in the same directory.
I was thinking along the lines of:
RewriteRule (.+).html pages.php?p=$1
The trouble is, the browser displays 400 Bad Request errors.
I'm hoping there's a fix for this but I can't get my head around it.
Any help is much appreciated :)
Try this:
RewriteRule (.*)\.html pages.php?p=$1
I'm looking for help creating a mod_rewrite rule for my website.
Here is an example of what the current link looks like http://soccersurfer.com/profile.php?id=3 and I would like it turn into something like http://soccersurfer.com/players/cristiano-ronaldo/. I have a lot of links like this, so it's not as simple as doing it for one, but for "profile.php?id=X" where X is the profile number.
Any help would be appreciated.
Thanks
The easier way would be:
RewriteRule ^/players/(.*?)/$ profile.php?name=$1
And in profile.php, add a possible argument (the name one) which lets you search the player in the database by his name rather than his ID.
Hi i hve been running forum for quite while and people started using it for spam etc and now even though i took it down i still got like 100 clicks day for threads that dont exist and the forum is not existing too.
I tired of seeing this crap in my piwik stats i want to move it with mod rewrite so every time someone access
site.com/samples/forum he goes soemwhere else like actual redirect to fbi.com etc. better without showing my url of couse or just to some non existing folder so it does not triger my stats.
You're probably looking for something along the lines of:
RewriteEngine on
RewriteRule /samples/forum http://othersite.com/path [L,R]
(of course can flex if you need patterns, or for different paths) There are tons of handy options that you can use, all documented in Apache's documentation.
I'm not sure whether this is the origin of the bug I'm trying to solve, however, I'm still not sure I correctly understood Apache doc...
Let's say I wanna redirect
toto.page?a=2&c=546EUE&stuff=blah
to
index.page?view=Blahblah/Toto&a=2&c=546EUE&stuff=blah
Of course, if there was other parameters, they should be preserved too.
Is the following rule correct?
RewriteRule ^toto\.page$ index.page?view=Blahblah/Toto [NC,QSA,L]
Yes. That is correct.