Here I am facing a redirection problem when I make a GET request on my new form.
On an existing hosting, I added a domain to add some forms.
My tree is:
- www
- apps.monsite.com
- b3web
- .htaccess
I do not put you, but here are the elements that concern my problem.
here is the content of my .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/b3web
RewriteRule ^(.*)$ /b3web/$1
RewriteCond %{HTTP_HOST} ^(www.)?site.fr$
RewriteRule ^(/)?$ b3web/index.php [L]
RewriteCond %{HTTP_HOST} ^(www.)?site.com$
RewriteRule ^(/)?$ b3web/index.php [L]
When I access my new form with the url type: http://apps.mysite.com/monform.php, it appears correctly. If I add "? Uuid = jlerjlrjklr" I get the following redirection error:
Not Found
The requested URL /b3web/apps.monsite.com/bonsav.php&uuid=euiorprt was not found on this server.
Which is "normal" because the form is not in the "b3web" directory, and I do not understand why it is doing this redirection. How can I block this redirection without breaking the rest of the sites?
Thanks in advance
Vincent
Related
What i want is to stop direct user requests to online.php, but i want the page to be still accessable for the rewrite rules, here is my rewrite rule
RewriteRule ^/?#([A-Za-z0-9]+)$ online.php?username=$1
And that is what i have tried but it didn't work
RewriteCond %{REQUEST_URI} /online.php
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule .* page-not-found.php
The url of the original file which i want to hide is https://example.com/online.php?username=example
and the one that i only want to be accessed from is https://example.com/#example
With your shown samples and attempts please try following htaccess rules file. Please make sure:
To keep your htaccess and online.php file in same folder.
Clear your browser cache before testing your URLs.
RewriteEngine ON
##External redirect and blocking direct access for online.php file.
RewriteRule ^online\.php/?$ - [NC,F,L]
##External redirect and blocking direct access for online.php file.
RewriteCond %{THE_REQUEST} \s/online\.php\?username=(\S+)\s [NC]
RewriteRule ^ - [F,L]
##Internal rewrite rules to rewrite to online.php file.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/?$ online.php?username=$1 [QSA,L]
I am trying to redirect www.bostonmabl.com/400hitter/boxscore/?SeID=332&GmID=93091 to www.bostonmabl.com/400hitter/boxscore/332/93091/ in the event that a user enters an old non-clean URL. Below is my .htacess file which I tried placing in both the 'root' directory and the '400hitter' directory, yet neither is working. Any help is greatly appreciated.
RewriteEngine on
RewriteCond %{QUERY_STRING} ^SeID=([^&]+)&GmID=([^&]+) [NC]
RewriteRule ^/400hitter/boxscore/index\.php$ https://bostonmabl.com/400hitter/boxscore/%1/%2/? [R=301]
With your shown samples, please try following htaccess rules. Make sure your .htaccess rules file and index.php are residing in same folder.
Make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
##External redirect to new URL in browser.
RewriteCond %{THE_REQUEST} \s/(400hitter/boxscore)/\?SeID=([^&]*)&GmID=(\d+)\s [NC]
RewriteRule ^ /%1/%2/%3? [R=301,L]
##Internal rewrite in backend.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^400hitter/boxscore/(\d+)/(\d+)/?$ index.php?SeID=$1&GmID=$2 [QSA,NC,L]
NOTE: This solution assumes that you want to rewrite(in backend) to index.php(by seeing your attempted code) and pass SeID and GmID parameters/query string into it.
I use URL writing in the Web Server, after converting the URL provided by the user, and then passing it to the program processor in the Web Server. I have added .htaccess file in my domain folder root, like below the picture:
After I rewrite the rules in the .htaccess file, the error message is shown me:
This page isn’t working
www.everyoneknows.com.my is currently unable to handle this request.
HTTP ERROR 500
My problem sample
My website name which call is https://www.everyoneknows.com.my/customer/?loc=dashboard, this website is used PHP coding. I need to change last name ?loc=dashboard to dashboard. That means I want the result website name is https://www.everyoneknows.com.my/customer/dashboard
Below is my rewrite rules, but cannot work:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^everyoneknow\.com\.my [OR,NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.everyoneknows.com.my/$1 [R,L]
RewriteCond %{HTTP_HOST} ^everyoneknows\.com\.my [OR,NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.everyoneknows.com.my/$1 [R,L]
##External redirect to /customer/dashboard url rules here.
RewriteCond %{THE_REQUEST} \s/customer/?\?loc=(\S+)\s [NC]
RewriteRule ^ /customer/%1? [R=301,L]
##Internal rewrite rules to get it served by index.php file.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^customer/(.*)/?$ index.php?parameter=$1 [QSA,NC,L]
The result is shown like below picture:
If website name is https://www.everyoneknows.com.my/customer/?loc=dashboard, the result can run well:
Hope someone can guide me on how to solve this problem. Thanks.
I have a website (WordPress multisite) for which I've moved a bunch of content from the route domain (http://domain[dot]com) to a sub domain (http://sub.domain[dot]com). Now I need to direct users to all the pages of the route site (http://domain[dot]com/page) to their new location (http://sub.domain[dot]com/page). But... and here's the bit I'm really struggling with... I need to omit the route url from this re-write as there is another 'geo-redirect' in place that I need to not affect. What I need to do therefore is redirect ONLY those sub page and NOT the parent/main domain.
Here's (a recent iteration) of what I'm working with:
# ignore the home page, not working :(
RewriteCond %{HTTP_HOST} !^(.*)\.routetogreatness\.com$ [NC]
# redirect all the sub pages, works
RewriteCond %{HTTP_HOST} ^routetogreatness.com [NC]
RewriteRule ^(.*)$ http://global.routetogreatness.com/$1 [L,R=301]
Any help will be very gratefully received.
I think what you are searching for is a condition that checks if the file that is requested is not a filename. That's what RewriteCond %{REQUEST_FILENAME} !-f. It is true if %{REQUEST_FILENAME} (I believe an absolute path to a file on the server, based on the request), is not a file. (Please note: I haven't tested this code as I don't have access to a server at this location, but I think it should work.)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://sub.domain.com/$1 [L,R=301]
An other solution would be to only rewrite the url if the requested url contains a slash. It would redirect domain.com/folder/index.php, but not domain.com/index.php.
RewriteCond %{REQUEST_URI} ^/([^/]+)/(.+)$
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://sub.domain.com/$1 [L,R=301]
Okay, so the above solution didn't quite work out for me as it turned out that while this worked beautifully on sub/child page, it would skip over parent pages as well as the home page (like domain/news for example. I've eventually run with this:
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://sub.domain.com/$1 [L,R=301]
This just skips over the home page or root URL and redirects everything else, even 404s.
I have the following in my .htaccess - the clean url's declaration and the https redirect both work fine individually but put together are causing the continuous redirect error (this server is redirecting in a way which will never complete).
Here is my .htacess:
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
# force to use https
#RewriteCond %{HTTPS} !=on
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Any idea how i can resolve this?
Thank you
Hope I am not late as I stumbled through your same problem and figured out the conflict just a day ago.
Write the following in your .htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
The first rule will automatically redirect any HTTP requests to HTTPS and (through the crucial [L] tag) stop other substitutions which will mess up the page (specifically, images and CSS stylesheets would not be served).
The second one is the Yii suggested way to check whether a particular URL corresponds to a real file or directory and, if not, to forward the request to index.php (the bootstrap file for the Web application). (The rules in the application's configuration file should do the rest, then).