Redirect based on query string? - .htaccess

I am trying to update the .htaccess file to redirect web users from pages on older version of our site to our current site.
The old PHP files have no direct relationship to file names and extensions used on our current site.
For example:
www.mydomain.com/pages/site/properties/properties.php?id=Smith
To:
http://mydomain.com/properties/sally-smith/
Or:
www.mydomain.com/pages/site/properties/properties.php?id=Jones
To:
http://mydomain.com/properties/robert-jones/
My site has several more pages with same path but with different PHP id's. I am getting stumped on how to handle each individual id in writing a 301 redirect from old pages to their corresponding current pages.

Related

redirect numerous dynamic urls to home page via .htaccess

I am trying to clean up a previously hacked WordPress site, and domain name reputation, the site has new hosting and is now on a different CMS system, but there are hundreds of spam links in Google I need to get rid of, they look like example.com/votes.php?10054nzwzm75042pw205039
Domain name, then votes.php?**** etc.. Numbers letters all sorts.
So how do I redirect ANYTHING that starts with the domain name then /votes.php?***
Any help greatly appreciated
Unless you have multiple domains, you don't need to explicitly check the domain name.
To send a "410 Gone" for anything that contains /votes.php in the URL-path (and any query string), you can do something like the following at the top of your root .htaccess file using mod_rewrite:
RewriteEngine On
# Serve a 410 Gone for any requests to "/votes.php"
RewriteRule ^votes\.php$ - [G]
A 410 is preferable to a "redirect" if you want to get these URLs removed from the search engines as quickly as possible.
To expedite the process of URL removal from Google then use Google's Removal Tool as well.
If you redirect these pages to the homepage then it will likely be seen as a soft-404 by Google and these URLs are likely to remain in the search results for a lot longer.

Redirecting using .htaccess

I've got an odd redirect request, and I'm not sure if it is possible.
On the server we have a series of PHP files with a name similar to /title-of-the-page-####.php, where #### is an unique integer ID of the page.
I want to be able to redirect users from /#### to the full title of the page (as listed above). Is this possible from within an .htaccess file, and if so, how? (I would like to avoid listing all of the pages from within the .htaccess file)

How to use .htaccess to redirect to new website?

I have the website
http://oldname.edu/gailp2/CSSS508,
which I want to point to my new site,
https://newsite.com/site/gailp2csss508
I've tried a number of different ways to accomplish the redirect via .htaccess files.
First, I modified the .htaccess file in the folder CSSS508
as follows:
Redirect 301 / https://newsite.com/site/gailp2csss508
When I navigate to the old site (oldsite.edu/gailp2/CSSS508), I get the error
"We're sorry, we were unable to locate the site /gailp2csss508gailp2/CSSS508"
It seems to be concatenating the file directories onto the name of the new website??
I've also tried a number of different variations, for example, trying to modify .htaccess files in different directories -- all unsuccessful.
try this Redirect 301 /gailp2/CSSS508 https://newsite.com/site/gailp2csss508

Magento .htaccess Removal of index.php from Store Urls

I do not want my URLs on my Store to contain index.php. All my product pages can be accessed via addition of index.php and without it which is not good and I want to get rid of index.php from the urls.
For example, both of these urls display the same content, but I only want users to ever be directed to the second URL:
http://www.pudu.com.au/index.php/outback-mens-denim-cargo-shorts.html
&
http://www.pudu.com.au/outback-mens-denim-cargo-shorts.html
Likewise for content at the top level of the site:
http://www.pudu.com.au/index.php
&
http://www.pudu.com.au/
Magento adds the system endpoint (index.php) to the URL path based on a configuration setting. In the admin, navigate to System > Configuration. In the Web section, open the Search Engines Optimization group and set Use Web Server Rewrites to "Yes". You'll need to flush the configuration cache and redindex URL rewrites thereafter.

301 Redirect of Static HTML to Dynamic PHP Page

After upgrading our website, many old links that people have in blogs, etc. are now going to our 404 error page.
An example is: (using h#p b/c I'm a new user and can't post links)
h#p://www.site.com/pressreleases/some_release.html
h#p://www.site.com/pressreleases/another_release.html
These items are now part of a db-driven site and would be live here:
h#p://www.site.com/pressreleases/details.php?id=1
h#p://www.site.com/pressreleases/details.php?id=2
How can I set up the 301 to redirect
h#p://www.site.com/pressreleases/some_release.html
to
h#p://www.site.com/pressreleases/details.php?id=1,
and
h#p://www.site.com/pressreleases/another_release.html
to
h#p://www.site.com/pressreleases/details.php?id=2?
Thanks
Compose a .htaccess file in the pressreleases directory and specify the following:
Redirect 301 some_release.html details.php?id=1
If you would like to redirect using regular expressions, use mod_rewrite as explained here.
There are various options listed on this page.
If you have a lot of these URLs, and assuming you have access to the Apache config, consider creating a "redirects.inc" file in /etc/apache2 (or anywhere really) and then adding "include /etc/apache2/redirects.inc" to your virtual host. That way you have one place to add/update your redirects.

Resources