Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I want to point my subdirectory folder like this
www.FOLDERNAME.SITE_NAME.net
and write now its working like this
www.SITE_NAME.net/FOLDER_NAME
I already made a domain for my folder
I tried many htaccess but no luck at all.
Any help will be highly appreciated.
Hi did you try this one.
RewriteCond %{HTTP_HOST} ^FOLDERNAME\.SITE_NAME\.net$ [NC]
RewriteCond %{REQUEST_URI} !^/FOLDERNAME/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /FOLDERNAME/$1
RewriteCond %{HTTP_HOST} ^FOLDERNAME\.SITE_NAME\.net$ [NC]
RewriteRule ^(/)?$ FOLDERNAME/index.php [L]
I did not Try but I am sure it will work out your problem.
feel free to ask on the same.
TRY ( not tested )
RewriteEngine on
RewriteRule folder_name\.%{HTTP_HOST}%\.net
www.%{HTTP_HOST}%\.net/folder_name [NC,R=301,L,QSA]
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Actually i want to make auto redirect when open
from
test.com/login.php
to
test.com/login/
What should i put on my htaccess file.
You'd first redirect to pretty-url if the raw request matches:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /login\.php [NC]
RewriteRule ^login\.php$ /login/ [R=301,L,NC]
Now, you deal with the rewritten url to internally redirect to correct page:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^login/?$ /login.php [NC,L]
Have you tried something?
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^index/?$ index.php [NC,L]
Your rewrite module should be enabled for doing this?
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I ve looked into many examples in stackoverflow and couldn't find a working solution for me.
I have a wordpress blog set up in a subdirectory.
The blog sits under www.domain.co.uk/wordpress/
In order for my permalinks to work I did an htaccess rewrite rule which is this
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?domain.co.uk$
RewriteRule ^(/)?$ http://domain.co.uk/wordpress [L]
Is there a way to take out the /wordpress part on the URL?
I need it to point there but I want the /wordpress to be removed.
Any ideas?
I have now managed to solve this issue following this guide: http://www.optiniche.com/blog/145/wordpress-tutorial-install-wordpress-in-a-different-directory/
Remove the wordpress from the redirect in your rule (the http://domain.co.uk/ means there's an implicit redirect) and add a specific rule to internally rewrite instead:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.co.uk$ [NC]
RewriteRule ^ http://domain.co.uk/ [L,R=301]
# now silently rewrite to wordpress
RewriteCond %{REQUEST_URI} !^/wordpress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wordpress/$1 [L]
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have been trying to redirect all requests under a domain to an underconstruction folder with the following:
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/underconstruction/
RewriteRule ^ /underconstruction/ [R=301]
But it doesn't seem to work.
I tried this (and it works):
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/underconstruction/underconstruction.html
RewriteRule ^ /underconstruction/underconstruction.html [R=301]
But I don't see the images and CSS that it comes with it.
Does anyone have any idea?
Maybe one solution is to exclude all image and CSS files from the rule, like this:
Options +FollowSymlinks -MultiViews
RewriteEngine On
# Add or remove file types in the next line if necessary.
RewriteCond %{REQUEST_URI} !\.(css|jpg|png|gif|bmp|js) [NC]
RewriteCond %{REQUEST_URI} !underconstruction\.html [NC]
RewriteRule .* /underconstruction/underconstruction.html [R=302,L]
Other options are to replace relative with absolute paths in the links to those files or to use the BASE element as described in this answer
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have the following rules which works fine. It simply give me the ability to make virtual sub domains:
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.domain\.com$ [NC]
RewriteRule ^(.*)$ /projects/index.php?project=%2 [L,QSA]
When it's project.domain.com it's totally okay, however, I need to cover up project.domain.com/first/ to domain.com/index.php?project=%2&a=first and project.domain.com/first/second/ to domain.com/index.php?project=%2&a=first&b=second.
I've already tried couple of things, but none of them worked. I can list them but that's gonna be a little bit long with all the description. If anyone could help, that's great, otherwise please comment to update my question with whatever I've already tried and their results.
You may try this:
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !index\.php [NC]
RewriteRule ^([^/]+)/?([^/]+)?/? /projects/index.php?project=%2&a=$1&b=$2 [L,QSA,NC]
Option
If the redirection is to:
http://domain.com/index.php?project=%2&a=first&b=second
as in the last example, replace the previous rewrite rule with this one:
RewriteRule ^([^/]+)/?([^/]+)?/? http://domain.com/index.php?project=%2&a=$1&b=$2 [L,QSA,NC]
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
Here is my current .htaccess code
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
it is works only in removing .php extension
from
http://localhost/mysite/news.php?category=cat1&id=1
to
http://localhost/mysite/news/cat1/1/
and from
http://localhost/mysite/news.php?category=cat1&year=2011&month=10&day=25&id=1
to
http://localhost/mysite/news/2011/10/25/1
How to write complete .htaccess for the clean url above?
Try This
RewriteRule ^(.*)\/$ $1.php [NC]
for example
http://www.exapmle.com/contact-us/
Add an optional / to your pattern:
RewriteEngine On
# rewrite news articles and pass news id as a GET parameter to news.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/mysite/news/(\d+)/?$ /mysite/news.php?newsid=$1 [NC,L,QSA]
# rewrite all other page requests to .php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/mysite/(.*)/?$ /mysite/$1.php [NC,L,QSA]
You could just try a simple RewriteRule:
RewriteEngine on
RewriteRule ^/?(\w+)/?$ $1.php
This tacks on .php to any file-looking url: example.com/somethin becomes example.com/somethin.php, example.com/something/else/ becomes example.com/somethin/else.php, etc.
The only problem with this is if you try to access an actual folder, like example.com/images or something.