https://northbengaltourism.com/hotel-details/sikkim/lachung/NBTH0329/ is working properly by using:
RewriteRule ^hotel-details/?(.*)/(.*)/([^/]*)/$ hotel-details.php?hotdest=$1&hotcity=$2&hotelid=$3
in htaccess. But when the two middle parameters are missing, the page shows:
Error 404 (Not Found). https://northbengaltourism.com/hotel-details///NBTH0329/
I tried ([^/]*) in place of (.*) but no luck. Please help me to solve this.
Related
On my website I have files index.php,home.php,about.php
And The full url is
http://example.com/about.php
and the wired thing is that
http://example.com/about.php#foobar
also goes to the about page . I want to block anything after my files name and redirect it to 404.
I copied this from a similar post :
Rewriterule ([a-zA-Z]+).([a-zA-Z]+) - [L]
Rewriterule ([a-zA-Z]+).([a-zA-Z]+) - [R=404,L]
Its not working. can you help me please?
Edit: its not a hashmark related question.
I want to redirect 404 a url with a trailing path.
I think you are looking for this :
AcceptPathInfo Off
Source : http://httpd.apache.org/docs/2.2/mod/core.html#AcceptPathInfo
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
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
I need help with a URL problem I've encountered with a rewriteRule.
What I need it to do is following: example.com/en/page/page/
At the moment the following works fine: example.com/en/page/
But once it goes like "example.com/en/page/page/" I receive a 404 - page not found error even if the page in fact is located in the serverfiles.
The clue here is that I use a variable in the /en/ part of the URL (multilanguage system) and it seems that I cannot figure out how to get it to work with that included.
At the moment I have the following rewriteRule in my .htaccess file.
RewriteRule ^([^/]*)/([^/]*)/?$ index.php?lang=$1&uri=$2 [L]
Do any of you have a clue on what might work?
Best regards,
PureDarkness
You don't include anything behind the second /. You could try:
RewriteRule ^([^/]*)/(.*)$ index.php?lang=$1&uri=$2 [L]
And you can add [QSA] if you also need to get the parameters.
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.