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 uploaded a couple of PHP testsites on my web host, but all the URLs end with a .php.
How can I convert /image.php?id=1 to yoursite.com/image/1?
How can I get the $id from yoursite.com/image/1 if a visitor manually enters the URL?
In your .htaccess file make sure you have
RewriteEngine on and do the following:
RewriteRule ^image/([0-9]+)$ image.php?id=$1 [L]
For instance:
RewriteEngine on
RewriteRule ^image/([0-9]+)$ image.php?id=$1 [L]
This is assuming you're running a webserver that can handle .htaccess - you may also need to enable mod_rewrite
Enabling this is dependent on the webserver you're running, if it's apache2 you could do
a2enmod rewrite
and service apache2 restart
in your terminal.
If you're unsure if it is enabled or not; you can do
<?php
phpinfo();
?>
and look for mod_rewrite
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
Can someone interpret what this .htaccess means? Thanks!
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^abcdef\.com$
RewriteRule (.*) http://abcdef.com/$1 [R=301,L]
It's a redirect for URIs beginning with www (or any other subdomain).
The Rewrite says:
If the address the browser is pointing at doesn't begin with abcdef.com, then drop the preceding subdomain.
So if you point the browser at:
http://www.abcdef.com/homepage/
the server will redirect the browser to:
http://abcdef.com/homepage/
If the server has been accessed via a domain other than abcdef.com, redirect to abcdef.com with a 301 status code (permanent) and append anything that came after it, so mysite.com/contact.htm or even sub.abcdef.com/contact.htm would become abcdef.com/contact.htm. Could be used on a server hosting multiple domains which should all run from a single main domain, or a site owner has renamed their domain and wants their old links to carry over to the new website.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
For SEO and usability purposes you may want to redirect your visitors to open your site only through http://www.yourdomain.com
how to redirect throught www.
For SEO and usability purposes you may want to redirect your visitors to open your site only through http://www.yourdomain.com.
Some applications, including Magento, however, require additional modifications to make this redirection work properly.
First, you should open the .htaccess file in the Magento folder. In it locate the "RewriteEngine on" line and right after it add the following lines:
RewriteCond %{HTTP_HOST} ^yourdomain.com$ [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]
Once you do this, save the .htaccess file and log in to the administrative end of Magento.
Then go to the System > Configuration menu and from the left panel click the "Web" button.
Unfold the "Unsecured" set of options and change the "Base URL" option from http://yourdomain.com to http://www.yourdomain.com.
Save the changes and your Magento website will be running with www.yourdomain.com only!
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'm trying to utilise mod_rewrite allowing me to use domain.com/d4k1d to give the same effect as domain.com/link.php?link=d4k1d
At the moment I have this in my .htaccess although this seems to give me 404 errors.
RewriteEngine on
RewriteRule /(abcdefghijklmnopqrstuvwxyz[0-9]+)/ link.php?link=$1
I'm not too familiar with mod_rewrite etc. so I don't know where to go with this :S.
You need to include all of the letters inside of the character class (which can also be simplified). Your current rule only allows for a letter followed by one or more numbers:
RewriteEngine on
RewriteRule /([a-z0-9]+)/ link.php?link=$1
You need to remove the leading slash because it's stripped from the URI by apache before being used in rules that are in an htaccess file.
RewriteEngine on
RewriteRule ^([a-z0-9]+)/?$ /link.php?link=$1 [L]
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a file called video.php on my domain but want it on my subdomain.
now its like www.domain.com/video.php?id=parameter&fewotherparamer=1233
and I want to change it to
video.domain.com/video.php?id=parameter&fewotherparamer=1233
how would this be possible? I already tried to find out using google and the searchfunction here, but didn't find the point.
Thanks
add these directives to .htaccess file in domain.com root directory (or virtual host config) and make sure you enabled mod_rewrite module
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain.com$ [NC]
RewriteRule ^video.php$ http://video.domain.com/video.php [R=301,NC,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 10 years ago.
Improve this question
I've got some duplicate content and want to redirect to the right url (remove a part of the url and redirect)
Examples:
http://www.domain.com/en/url/1-url
http://www.domain.com/es/url/1-url
http://www.domain.com/fr/url/1-url
....
The individually should redirected to:
http://www.domain.com/en/url
http://www.domain.com/es/url
http://www.domain.com/fr/url
....
Because I have to do this for a lot of urls, I can't redirect them each manually and need a rule which detects if the url contains "/1-url" and if yes remove this part from the url - but only this part.
Would be great if a mod-rewrite hero can help me with this. I'm searching for solution over .htaccess via a rewrite rule.
Check this:
RewriteRule (\w{2})/([^/]+)/\d+-[^/]+$ /$1/$2 [R=301,L]
RewriteRule ([^/]+)/\d+-[^/]+$ /$1 [R=301,L]
If you use a imported file to each 1-url page only add redirect method to imported file.
For example your every 1-url page have header.php, add redirect function to header.php