There are several links on third party websites to a URL on my website:
http://example.com/cgi-bin/sp000000.pl
That script is no longer present.
Is there a way to redirct that URL to another using .htaccess or a .pl script?
You can use this simple rule:
RedirectMatch 301 \.pl$ http://example.com/
Related
My provider supports a web-analytics tool named Awstats on every website they are hosting. I don't want this service anymore but I can't tell them to remove it. That's why I need to ban it with the .htaccess.
I want that everyone who requests www.example.de/logs to be redirected to www.example.de/. How can I do that? I have nearly no experience with .htaccess files.
.htaccess redirect
To use .htaccess redirect one page to another page or website do the following:
Use:
Redirect 301 /folder http://www.example.org/
or
RedirectMatch 301 /folder http://www.example.com/
In your case you may add this inside your .htaccess file at your website root level, ie. public_html/.htaccess
Redirect 301 /logs http://www.example.de/
I am working on a site that uses such a url
www.domain.com/hotels/hotel-name
I would like visitors just to see
www.domain.com/hotel-name
This can probably be done in the .htaccess file with a rewrite condition but I don't know how.
Thank you for helping
You can use RedirectMatch directive :
Put the following Redirect above other rules in your htaccess file
RedirectMatch 301 ^/hotels/([^/]+)/?$ /$1
This example would redirect all files from the /hotels/ folder, if you want to redirect a particular file from that folder , you can use the following:
RedirectMatch 301 ^/hotels/(file_name)/?$ /$1
Now if a visiter enters www.example.com/hotels/hotel-name then will be externally redirected to www.example.com/hotel-name
I'm using mod_rewrite. The .htaccess contains this line:
# redirect old references
Redirect 301 /folder/ http://www.donain.de/folder
This works fine execpt for one thing: All requests to subfolders are redirected as well. For example: /folder/hello is redirected to /folder. How can I prevent this?
I know that I can determine the start of an expression using ^ in a .htaccess file. But I can't figure out to say "stop this rule there".
You need to use RedirectMatch for regex support:
RedirectMatch 301 ^/folder/?$ http://www.donain.de/folder
i have to redirect one url to another. http://www.abc.com/realestate/ to Redirect to http://www.abc.com/businessfinder/company/4105/Property_Agent/. is it better to change on the codeigniter routes.php or the .htaccess file?
If you know that a URL should be redirected then there is no reason to hand the request to PHP. So, redirecting using the .htaccess file would be preferable.
If you have mod_alias installed then you can use the Redirect directive:
Redirect 301 /realestate/ http://www.abc.com/businessfinder/company/4105/Property_Agent/
You can also use mod_rewrite to jump between places in various ways. E.g.:
RewriteRule ^/realestate/?$ /businessfinder/company/4105/Property_Agent/ [R=301,L]
If that is not possible then you can use CodeIgniter's $this->url->redirect() method. It will send the user to any website you like.
I am using the Redirect directive for redirecting a short URL to a particular URL in .htaccess file.
For example:- Redirect /hello http://hello.com
How can I redirect two URLs to the same URL?
For example:- Redirect /hello1 /hello2 http://hello.com
You can use RedirectMatch for regex capabilities:
RedirectMatch ^/(hello1|hello2) http://hello.com