Google Webmaster tools gives me a hint that I have 2 pages with the exact same content.
For example:
/airports/romania/115.php
/airports/romania/115.phphey1
In the htacces file i have this:
RewriteRule airports/(.*)/([0-9]{1,}).php airports_list.php?airport=$2&country_air=$1
I've checked and double checked and triple checked all my code in airports_list.php and every other file on the server. I can't find "hey1" anywhere.
In order to solve my problem, I think I have to redirect a link like www.mydomain.com/airports/romania/115.phphey1 to a 404 page.
How do I do that ?
The following is also working inside my .htaccess file :
ErrorDocument 404 http://www.mydomain.com/404.php
If you put a dollar sign at the end of the regex, it stops matching and so garbage at the end of '.php' and goes to the 404.
RewriteRule airports/(.*)/([0-9]{1,}).php$ airports_list.php?airport=$2&country_air=$1
Related
I've installed Laravel October CMS. When I access http://localhost/index.php/backend, I can see the loging page of the backend. When I access http://localhost/backend I've 404 Not Found.
I've taken a look to .htaccess, I've uncommented the RewriteBase and set the value / /index.php.
However it still returns a 404. Do you know why?
I believe you are simply looking for following Rule based on your shown samples. Also please make sure you clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteRule ^backend/?$ index.php [NC,L]
In case this is the only rule of your htaccess file then change L to END in above.
Please can someone explain what is happening here? This .htaccess correctly redirects to that page in the root directory but all the links on the page now include a (non-existent) sub-directory "test" (though the html source doesn't)
RewriteEngine on
RewriteBase /
RewriteRule ^test/([0-9]+)/?$ /view_player.php?player=$1
ps the same thing happened before I put in the "RewriteBase /" and "/" before the view_player.php destination, they were included in my attempt to find out what is happening.
What do I need to do to stop this happening?
In your RewriteRule, you will see there is a section that says ^test/. This is known as a prefix and you can use this to modify your URL and therefore improving the form of the rewritten URL and increasing its relevancy.
So for example, if I had a URL that read:
www.exmaple.com/common-errors/an-error
I might what to include a prefix called errors, and therefore rewriting it to:
www.example.com/errors/common-errors/an-error
I am having some issues trying to prettify some URL's. Basically I need to make this URL http://domain.com/actualfolder/fakepath/this-is-the-article.php to display content from this page http://domain.com/actualfolder/articlemanager.php.
The articlemanager.php is setup to receive a GET url variable in the way of the "this-is-the-article" and search for it in the database. If found, it will display content specific to that result. This part works.
The part that i can't make it to work is the htaccess rule.
This is my rule but it returns 404 not found or 500 if i don't use the initial slashes.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^fakepath/([^/.]+).php$ articlemanager.php?permalink=$1 [L]
I could really use some help, so any suggestion is welcome.
EDIT: the htaccess file lies in the domain.com/actualfolder/ location
This is the contents of my .htaccess file:
RewriteEngine on
RewriteRule ^upload$ upload.php
RewriteRule ^/(\d+)/?.*$ /view.php?id=$1 [L]
The first rule successfully works. When I navigate to http://localhost/upload it shows the upload.php page.
The second rule however, does not. When I browse to: http://localhost/1234/some-string I get a 404 error. It's meant to show this page: http://localhost/view.php?id=1234.
Hopefully you can see what I'm trying to do with the rule, I want the last string on the end of the URL to be completely ignored, and take the 1234 as a parameter for view.php.
Can anyone spot why this isn't working? I've tried everything I can think of, but to no success. Thanks!
it will be trying to find the directory /1234/ and failing. change the / to a - and it should work
EDIT: got that completely wrong ... it's actually that you have a / at the beginning of your pattern, whereas MOD_REWRITE receives the path without the first slash.
I have a link from anther website that I do not have control of http://example.com/one two three.exe
The correct URL is http://example.com/one_two_three.exe
Note the underscores instead of spaces.
I searched the internet and found this code snippet for .htaccess
# Redirect old file path to new file path
Redirect /one%20two%20three.exe http://example.com/one_two_three.exe
I added this snippet to my preexisting root .htaccess at the top of the file.
But it does not seem to work. My browser does not redirect and I get a 404 error page.
I believe that it has something to do with the spaces in the original URL but I don't know how to handle spaces in the URL.
Suggestions?
You could try a couple of things (both untested)
Redirect "/one two three.exe" http://example.com/one_two_three.exe
or use RewriteRule instead of Redirect:
RewriteRule /one\ two\ three.exe http://example.com/one_two_three.exe