I want:
domain.com/example
to target:
domain.com/folder/example.cshtml
Can anyone help me with the rewrite rule for it?
Every suggestion is much appreciated :)
I have edited the question so that it actually focuses on what is important.
why aren't you using mod-rewrite?
RewriteCond %{THE_REQUEST} /folder/example.cshtml
RewriteRule ^$ /example.cshtml [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^example.cshtml /folder/example.cshtml [L]
Sometimes you need to mess around with the slashes a bit
I guess it can't be done the way i want it.
I'll have to move example.cshtml to the root directory.
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.
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 have been searching for a long time now with no success, and I am almost there. However, I need to create this rule:
www.webpage.com/index.php?variable=x
to
www.webpage.com/x and www.webpage.com/x/
So far I have this code in .htaccess:
^([^/]*)\.html$ /index.php?nombre=$1 [L]
and what it helps me is in putting getting what I need but with .html
www.webpage.com/x.html
and I need
www.webpage.com/x
Thanks in advance! :D
Assuming you're using mod_rewrite, try:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ /index.php?nombre=$1 [L]
I would like to be able to use rewrite rules to redirect anyone who opens the link :
domain.com/name
to
index.php?username=name
what would be the best way to do it?
I tried to post the htaccess code I wrote but stackoverflow keeps saying it doesn't meet standards so I removed it.
thanks in advance
Something like this will do it:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/([^/]+)/? [NC]
RewriteRule .* index.php?username=%1 [L,QSA]
It will map silently
http://domain.com/name
To
http://domain.com/index.php?username=name
For this to work, /name must be the first directory in the incoming URL path.
I've just learned a bit of CodeIgniter Framework and I saw something which I wondered a long time ago.
CodeIgniter handles Routing just as this:
http://mydomain.com/index.php/classname/function/parameter
Now I want to get this to work:
http://mydomain.com/classname/function/parameter
Is it somehow possible to get the webserver to not check for the directories but to forward those parameters to mydomain.com/index.php? Is this somehow realizable by .htaccess or something?
Thank you for help!
Here is the help regarding this http://codeigniter.com/user_guide/general/urls.html
or Place
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
in your .htaccess