Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm trying to rewrite URL, so when a user accesses
mysite.com/something
I want it to show up the content of mysite.com/something.php, but not redirecting the user to the actual .php file.
I have many other pages like this, I want a one-for-all (wild-card) soltion, rather than setting up lines for each file.
Is there a way to do it using .htaccess?
P.S: I don't want mysite.com/something.php to be redirected to mysite.com/something too.
You can do that with MultiViews option:
Ad this line on top of your DOCUMENT_ROOT/.htaccess file:
Options +MultiViews
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need the following help:
Force homepage index.php to redirect to index.php?page=xx
How?
You could use this to redirect the users to the page you wish:
/* Redirect browser */
header("Location: http://theos.in/");
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I currently have the page '/tags.php?id=foo', and want it to display in the browser as '/tags/foo'. How might I do this with the .htaccess file?
EDIT
I've tried the solution given below and read up a little bit on Regex, but it's still not quite working how I need it to - is it possible once using the .htaccess mod_rewrite to still derive the $_GET data from the URL to use in code?
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^tags/([^/]+)/?$ /tags.php?id=$1 [L,QSA]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I would like to replace my links appeared in my page's adressbar.
Now the links have this format: http://mypage.com/index.php?page=contact
And I want this format: mypage.com/contact
How to do that?
(No links please, I need example.)
Update:
This is one possible solution that worked:
RewriteEngine on
RewriteRule ^([^/.]+)?$ index2.php?page=$1 [L]
Take a look at htaccess and mod_rewrite.
You asked for no links, so I'll let you Google them yourself.
Once you have a chosen path, try it out and if you can't get it working come back with examples of what you've tried and in what way they didn't work.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
This is hard to explain, better with an example...
I have this valid url: www.sitetoautenthicate.com/portal/index.php.
To access this page, I want to mask the url to www.sitetoautenthicate.com/portal/myportal/index.php where myportal has to be authenticated (exists in database) through an external API (ajax post).
I also want to forbid access to www.sitetoautenthicate.com and www.sitetoautenthicate.com/portal/
I think this can be done only with .htaccess
I also want to forbid access to www.sitetoautenthicate.com and www.sitetoautenthicate.com/portal/
Try this rule in in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.sitetoautenthicate\.com$ [NC]
RewriteRule ^(portal)?/?$ - [F,NC]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have the following URL:
www.mysite/apage.php?product_id=295-Product-name-in-a-color
I would like the following:
www.mysite/id=295-Product-name-in-color
The product name and colour are triggered from a different page.
I can redirect the actual apage.php using .htaccess however I lose everything else and it won't find my page.
Any help welcome
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^id=([^/]+)-(.+)$ /apage.php?product_id=$1-$2 [L,QSA,NC]