I'm a complete novice when it comes to htaccess. I've searched for my exact problem to no avail.. perhaps I did not even know what to search for, haha.
Goodness, the title of this question might not even be appropriate!
Here goes:
I need:
https://www.example.com/1 (the 1 (one) at the end will be inserted by the user. So, it may be https://www.example.com/2057 for example. What ever the number at the end, I need it to go to:
https://www.example.com/folder1/folder2/1 (or what ever number is inserted.)
The closest I've come to is this:
RewriteRule ^/(.*) folder1/folder2/%1/index.php? [R,L]
However, this gives a VERY long example.com/folder1/folder2/folder/1/folder2.....for a LONG time.../1.php
Any help would be greatly appreciated.
This seems to work in may case:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.*) http://www.examplesite.com/folder1/folder2/$1 [R=301,L]
This worked at time of this posting. Hope it helps someone in the future.
RewriteEngine on
RewriteRule ^([0-9]+)((?:A|L)[0-9]R[0-9]+[A-Z]?)$
https://www.mywebsite.com/folder/$2&login=$1 [L]
RewriteRule ^([0-9]+)((?:A|L)[0-9]?)$ https:/www.mywebsite.com/folder/$2&login=$1 [L]
RewriteEngine on
RewriteRule ^([0-9]+)$ https:/www.mywebsite.com/folder/$1 [R=301,L]
Related
I'm a newbie with htaccess file so please bear me with my ignorance.
I'm working on a code-igniter project whereby I require to add exception for a particular URL say : www.domain.com/leaveit/file
Basically I have placed a folder at the root which I need to bypass from the rule written in htaccess file where by index.php is added for every request made.
Any suggestion / link would be highly appreciable as I have searched a lot for the solution but didn't end up with anything concrete to help me out of this issue.
Here's my htaccess code.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
php_flag output_buffering On
Thank in advance for your time and patience.
Simply try this
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|leaveit)
RewriteRule ^(.*)$ /index.php/$1 [L]
Let us know if your problem solves or not.
Im a bit stuck where I need to redirect 80+ URLs' which have
content.php?111-rest-of-url
RewriteCond %{QUERY_STRING} ^?64-random-url-here-again$
RewriteRule ^content.php$ https://www.newdomain.com/random-url-here-again/? [R=301,L,QSD]
RewriteCond %{QUERY_STRING} ^?61-random-url-here$
RewriteRule ^content.php$ https://www.newdomain.com/random-url-here/? [R=301,L,QSD]
And there are around another 80 url's written out like this. However, when testing on site, no matter what URL you try...it always returns the first one in the .htaccess
From what I have been reading am I correct in assuming you can only use one query string of this kind ? if so is there away around this ?
Thanks in advance.
Ok so I managed to accomplish what I need by doing the following, hopefully it will help someone else.
RewriteCond %{REQUEST_URI} ^/content\.php$
RewriteCond %{QUERY_STRING} ^196-random-url-here-again$
RewriteRule ^(.*)$ https://www.newdomain.com/random-url-here-again/? [R=301,L,QSD]
RewriteCond %{REQUEST_URI} ^/content\.php$
RewriteCond %{QUERY_STRING} ^196-random-url-here$
RewriteRule ^(.*)$ https://www.newdomain.com/random-url-here/? [R=301,L,QSD]
Not sure what the difference is but it works :), would be grateful to hear from someone to explain the difference in what I have done so I understand it in the future.
Alright I've searched and looked at at least 20 ways to turn site.com/profile?page=username
to just site.com/username
and they DO work, but when I do it and go to the page it starts off loading normal, then completely glitches and continues to glitch and break the page.
I really don't know what to do at this point. I don't know if it's just GoDaddy and I need something specific or what.
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^profile/([^/]+) /profile.php?page=$1 [NC]
RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?page=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?page=$1
is the current one i've tried
Solved
I ended up finding someone who posted this, and it worked!
RewriteRule ^([^/]*)/$ /profile.php?page=$1 [L]
I have this profile page which will show your profile with the url
localhost:8080/profile?username=ImSchnebz
But the thing is I want it to look like this:
localhost:8080/profile/ImSchnebz
I have tried a lot of different answers, but most of them give me 404 not found or 500 internal server error, I know this isn't anything you guys could help me with, but I've asked this question before, and gotten no response, so please, if there is anyone out there, please help me! :)
Thanks
EDIT:
I have this code
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /profile.php?username=$1 [L,QSA]
And it works perfectly with localhost:8080/ImSchnebz but I want it to be localhost:8080/profile/ImSchnebz
Try
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/profile/(.*)$ /profile?username=$1 [NC]
Based on the link #Lawrence gave.
Try this:
RewriteEngine on
RewriteBase /
RewriteRule ^profile/(.*)$ profile.php?username=$1 [L,QSA]
I give up. I have read through dozens of questions on here, even asked my own, I have tried numerous things, I just don't know what to do anymore.
I need to create url's out of the following formats: (NSFW links, be warned)
http://jbthehot.com/#page=1
http://jbthehot.com/home?func=viewphoto&id=2969
http://jbthehot.com/home?page=4
http://jbthehot.com/home?func=viewalbum&aid=75
I must be retarded because I simply do NOT understand htaccess. I try not to ask for all-done answers, but in this case, an actual clear, copy/paste answer for at least one of the above formats would really be helpful.
I repeat, I have tried a lot of things, so I'm obviously doing something wrong, or I'm not understanding the rules and conditions right, so a copy/paste answer that is SURE to work would really help me understand what I'm doing wrong here.
If it helps, the component used here is SIM Gallery, on Joomla and there are a couple of other rewrite rules in effect in the .htaccess , here they are:
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
Thank you for any help
RewriteEngine On
RewriteBase /
RewriteRule ^home/viewphoto/([0-9]+)$ home?func=viewphoto&id=$1 [L]
RewriteRule ^home/viewalbum/([0-9]+)$ home?func=viewalbum&aid=$1 [L]
RewriteRule ^home/page/([0-9]+)$ home?page=$1 [L]
So http://jbthehot.com/home/viewphoto/2969 would show you http://jbthehot.com/home?func=viewphoto&id=2969, etc