Guess i'm toast then.. http://www.mardy-bum.com/index.php?page=music should redirect to http://www.mardy-bum.com/site/music/. Although it seems to be a bit non functional at the moment.
Try RewriteCond %{QUERY_STRING} ^page=[^&]+)?$ RewriteRule ^index\.php?page=([^.]+)$ http://www.domain.com/site/$1 [R=301,L] A code that I've used that works is... RewriteCond %{QUERY_STRING} ^t=23044(&page=[^&]+)?$ RewriteRule ^showthread\.php$ http://forums.digitalpoint.com/showthread.php?t=666 [R=301,L] but that was for just one thread in a vBUlletin board. For example, this thread and all it's pages. The code being if this thread moved to showthread.php?t=666
I got an error when I tried that: and from looking at the other example I assumed you missed out the beginning (, so I put that back in and i'm still not getting anything unfortunately. The rest of my url rewrites are working fine, though.
Ok. I have called my buddies (all two of them). I have looked in an Apache book. I have Googled it. Finally, I sacrificed a chicken on the keyboard. I still cannot solve this stupid redirect problem I have been having. Someone save me. I just want to redirect all traffic from an old non-functioning URL to a new subdomain: from this URL: http://geekz.us/?q=arsfiles to this one: http://arslist.geekz.us I have tried the following to no avail: Redirect ^http://geekz.us/?q=arsfiles$ http://arslist.geekz.us [r] Redirect /\?q=arsfiles http://arslist.geekz.us Redirect /?q=arsfiles http://arslist.geekz.us RewriteRule ^$ /?q=arsfiles RewriteBase / RewriteRule ^/?q=arsfiles$ http://arslist.geekz.us So I am pretty sure my google-fu and my .htaccess-fu are both The Suck(C). Anyone shed some light here in this darkness? Thanks!
Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^index.php?q=(.*)$ http://arslist.geekz.us [R=301,L] with index.php being what ever the script name is.
Almost. See, my original url was http://geekz.us/?q=arsfiles since I was using Drupal. I have since stopped using that CMS and am moving the content the old url pointed at to a subdomain. I still have www.geekz.us which has other content that I still want users to reach. When I tried your solution, I got an internal server error on http://www.geekz.us and on http://arsfiles.geekz.us Of course, this is farther than I have gotten yet Since there was no original script like index.php? i just tried this: RewriteRule ^/?q=arsfiles(.*)$ http://arslist.geekz.us/ which did not work. Any other ideas? PS Thanks for the response Nintendo, I appreciate it.
Do a test to see if you even got mod_rewrite. Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^wacko\.html$ index.php [R=301,L] domain.com/wacko.html should show the same thing as the index page. Try it with out the first two lines if it doesn't work.
Yes, that works. I kind of new it worked because I already have another redirect setup like so: Redirect /ars.asp http://arslist.geekz.us I have been through three CMS's running this site. I used to have this in the file which worked perfectly: redirect permanent /ars.asp http://geekz.us/?q=arsfiles That was for my switch from static pages to the first CMS (Drupal). Now I am switching to Wordpress, but I want to redirect two links which I have used and been linked to by other sites so that folks hitting those links still get directed to the proper address. As of right now Redirect /ars.asp http://arslist.geekz.us works perfectly, and now I just need to get these two pointing to http://arslist.geekz.us without hosing the rest of the site: http://geekz.us/?q=arsfiles (Drupal) http://geekz.us/viewpage.php?page_id=46 (php-fusion) I see not why so many folks have been using URL rewriting. It sure makes things easier when you decide to change CMS's. Thanks for your help. I am a programmer/consultant by trade, but I cannot seem to wrap my brain around this .htaccess stuff.
Too my knowledge, there wasn't a file. This was from the Drupal CMS which I used first. I thought it was wierd, but it is the way it was displayed in the browser. All my links internally were like that too. I still have some old backups of the entire site when it was running like that so I can still look at the old files, sql dumps, etc. Beats me.
Just dug through the old .htaccess. Here is a clip from the end where I had redirected the static pages to the Drupal dynamic ones: redirect permanent /ars.asp http://geekz.us/?q=arsfiles redirect permanent /notes.asp http://geekz.us/?q=gz_notes redirect permanent /index.asp http://geekz.us/?q= redirect permanent /ars/Compression.asp http://geekz.us/?q=ars_compression It worked great. But when I tried to "reverse" the idea it bombs on me of course.
There has to be some file that's making that page. A page doesn't come out of nothing. There's no way to do mod_rewrite unless you know what it is. Look in the directory for something like index.XXX
Well. I agree that there is usually a page which references this. But I swear my links I left in forums (which worked fine) did not include a page. My only guess is that the parameters were passed to the index.php file which was live at that time, but is not now. I know it looks wierd, but http://geekz.us/?q=arsfiles always took you to the right page when I was using Drupal. I never liked it and never could get static links to work properly within the CMS. Is there anyway to redirect just using a substring like "arsfiles"? Or is there any type of aliasing that can be done? I am such an .htaccess noob. Thanks for the tips,
http://geekz.us/index.php?q=arsfiles Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^index\.php?q=(.*)$ http://arslist.geekz.us [R=301,L] at http://geekz.us/.htaccess and you can try RewriteRule ^index\.php?q=arsfiles$ http://arslist.geekz.us [R=301,L] if it's just http://geekz.us/index.php?q=arsfiles that you want to be redirected. And you can try it with out Options +Indexes Options +FollowSymlinks
I'm having a change round in one of my sites and have the following to write database content in a more user friendly URL: RewriteRule ^property_forsale_details-([0-9]*).html property_forsale_details.html?listingID=$1 However I'll be wanting to delete about 75% of these pages, so will I'll be able to add a redirect for the old pages after this rewrite rule or do I have to do it another way?? Thanks Ian
If it's static URLs going to new URLs you should be able to redirect them. Redirecting dynamic URLs are more challenging.
Gah, can anyone help me in achieving the following. http://www.boredombase.com/profile.php?name=admin to: http://www.boredombase.com/user/admin
That didn't seem to work but my friend told me: RewriteRule ^user/([^/\.]+)/?$ profile.php?user=$1 [L] would.
he was wrong, send me some ftp access or try : RewriteRule ^user/(.*)/?$ /profile.php?name=$1 is it ?user or ?name ? also, the full code should look something like RewriteEngine On RewriteBase /. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/user/(.*)/?$ /profile.php?name=$1 Code (markup): not just the one liner, you prolly got that but you never know who is reading ......