|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
general - Redirecting dynamic urls to static ones w/htaccess
Hi there,
I've been searching quite a bit for a solution, but thus far, none of them have worked properly. I can redirect static urls to static urls just fine, but when I try and redirect an old dynamic url to a static one, it redirects, but it adds the query string to end of the url (i.e. www.nwcolorado.com/? or www.nwcolorado.com/?listingID=201). I want to redirect: http://www.nwcolorado.com/NWR_Listingview.php?listingID=201 to: http://www.nwcolorado.com/ How would I accomplish this? Also, is there a simple way to do this for all dynamic urls using "NWR_Listingview.php" as the base? Reason I ask is that there are several listings that need to be redirected to the home page. Here's my htaccess file thus far: Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
<Files 403.shtml>
order allow,deny
allow from all
</Files>
deny from 91.74.160.18
RewriteCond %{HTTP_HOST} ^nwcolorado.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.nwcolorado.com$
Redirect 301 /NWR_BuyingProcess.php http://www.nwcolorado.com/contact-us/
Redirect 301 /NWR_Buyingsellingtips.php http://www.nwcolorado.com/help-faq/real-estate-tips/
Redirect 301 /NWR_Contactus.php http://www.nwcolorado.com/contact-us/
Redirect 301 /NWR_Localphotogallery.php http://www.nwcolorado.com/local-information/fort-collins-photos/
Much thanks in advance. |
|
#2
|
|||
|
|||
|
Just to be clear, I don't want to rewrite the old urls, I want to redirect them to the main domain. I'm throughly diving through the web looking for viable solutions, but still no luck.
I generally don't rush people for help, it's just that I took this client's site live recently and the search engine spiders are very active with it. Thanks. |
|
#3
|
||||
|
||||
|
Doing the redirect with mod_rewrite would probably remove the query string.
You could also just redirect in the NWR_Listingview.php PHP, no?
__________________
# Jeremy Explain your problem instead of asking how to do what you decided was the solution. |
|
#4
|
|||
|
|||
|
Quote:
Hi Jeremy, Thanks for your help. I tried putting the code below in the .htaccess file, but it didn't work. Is there something I'm doing wrong? : Code:
RewriteRule ^NWR_Listingsearch.php$ http://www.nwcolorado.com/? [R=301,L] Now my htaccess file is like this: Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
<Files 403.shtml>
order allow,deny
allow from all
</Files>
deny from 91.74.160.18
RewriteRule ^NWR_Listingsearch.php$ http://www.nwcolorado.com/? [R=301,L]
Redirect 301 /NWR_BuyingProcess.php http://www.nwcolorado.com/help-faq/real-estate-tips/
Redirect 301 /NWR_Contactus.php http://www.nwcolorado.com/contact-us/
Redirect 301 /NWR_Localphotogallery.php http://www.nwcolorado.com/local-information/fort-collins-photos/
I don't want to redirect via the NWR_Listing.php page for SEO reasons, something I just learned late last night from one of Matt Cutts' videos (the head of Google's Webspam team). Thanks. |
|
#5
|
||||
|
||||
|
It should be ^NWR_Listingsearch\.php$ but that shouldn't prevent it from matching. You might add the NC (no case) flag, too.
|
|
#6
|
|||
|
|||
|
Quote:
Thanks again for your continued support. I tried what you suggested, minus the nc part for now, but no dice. Here's what I have thus far: Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
<Files 403.shtml>
order allow,deny
allow from all
</Files>
deny from 91.74.160.18
RewriteRule ^NWR_Listingview\.php$ http://www.nwcolorado.com/ [R=301,L]
Redirect 301 /NWR_BuyingProcess.php http://www.nwcolorado.com/help-faq/real-estate-tips/
Redirect 301 /NWR_Contactus.php http://www.nwcolorado.com/contact-us/
Redirect 301 /NWR_Localphotogallery.php http://www.nwcolorado.com/local-information/fort-collins-photos/
|
|
#7
|
||||
|
||||
|
I don't see any issues with your syntax. Your next step is to enable a RewriteLog, which requires access to httpd.conf, and to remove other directives to see how their existence affects your rule.
Note that without the NC flag, you must request NWR_Listingview.php case correctly or the RewriteRule will not match. |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > general - Redirecting dynamic urls to static ones w/htaccess |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|