.htaccess
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.php$
RewriteCond %{REQUEST_URI} !\.(gif|jpeg|jpg|png|css|js|wiff|woff2|ttf)$
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
Example of working urls
http://www.website.com/u/johndoe/asdf
http://www.website.com/u/johndoe/
Unique Error
http://www.website.com/u/johndoe
In the unique error case, the url is changed to:
http://www.website.com/u/johndoe/?path=u/johndoe
does anyone know why the ?path=u is being adding to the url?
It is physically in the url field at the top of the browser.
Is there a way to fix this?
Related
I have link like this: http://site.crm.int/project_discussions/test
I need redirect it to : http://site.crm.int/project_discussions/index.html?url=test
Text 'test' is changable. Can be for example 'december', 'meetting01' etc.
I tried it in my .htaccess:
RewriteRule ^\/project_discussions/(.*)$ \/project_discussions\/index.html?url=%1 [L]
But have 404 error.
Also tried this:
RewriteCond %{REQUEST_URI} ^/project_discussions/(.*) [NC, L]
RewriteRule ^(.*)$ /index\.html?url=$1 [L,NC]
And have 'Internal Server Error'
How can i fix it? thanks
With your shown samples, please try following .htaccess rules file. Make sure .htaccess file and folder project_discussions are residing in same root folder. Also your index.php OR index.html file should be inside your project_discussions folder.
Make sure to clear your browser cache before testing your URLs.
Also I have fixed your previous rule for handling internal rewrites.
RewriteEngine On
RewriteBase /project_discussions/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/?$ $1/index.html?url=$2 [R=301,NE,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 cant figure out how to redirect all requests except my ip to a subfolder in .htaccess
I came up with
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !=123.45.67.89
RewriteRule ^$ /coming-soon/ [L]
RewriteRule (.*) http://example.com/coming-soon [R=301]
But when i write in browser for example example.com/asdasdas it gives me
coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon
What i would like to achieve is when user enters anything that it redirects to example.com/coming-soon unless it is my IP. I did research on SO, but I always get stuck.
Also there is a folder in the root /coming-soon with images and fonts for that html
Any help would be appreciated
You can use this :
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !=123.45.67.89
RewriteCond %{REQUEST_URI} !^/coming-soon [NC]
RewriteRule (.*) http://example.com/coming-soon [R=301,L]
Make sure to clear your browser cache or use a different browser to test this code.
I have a full site setup at mysite.com/2/
I want urls like:
mysite.com/about to redirect to mysite.com/2/about
mysite.com/work/photos to redirect to mysite.com/2/work/photos
I was hoping I could solve this and add the /2 after the domain through the htaccess file and not have to move the whole site up a level.
Try the folowing code if you want redirect
RewriteEngine On
RewriteCond %{REQUEST_URI} !(about|work/photos)/(2)
RewriteRule ^(about|work/photos)/(.*)$ /$1/2/$2 [R=301,L]
If you need only internal redirection change the last line with this :
RewriteRule ^(about|work/photos)/(.*)$ /$1/2/$2 [L]
If you want to change all requests :
RewriteEngine On
RewriteCond %{REQUEST_URI} !/(2)
RewriteRule ^(.*)/(.*)$ /$1/2/$2 [R=301,L]
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