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 ]
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 1 year ago.
Improve this question
I want to redirect all the links that have specific parent to a subdomain, while preserving url structure.
Example:
domanin.com/topic1/subtopic1/subtopic2/
redirect to
sub.domain.com/topic1/subtopic1/subtopic2/
Thank you.
To redirect all requested URLs that start /topic1/ (the "specific parent") from example.com to sub.example.com then you can do something like the following using mod_rewrite at the top of your .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?(example\.com)
RewriteRule ^topic1(/|$) https://sub.%1%{REQUEST_URI} [R=302,L]
This will 302 (temporary) redirect URLs of the form:
example.com/topic to sub.example.com/topic (which will also redirect to sub.example.com/topic/ by mod_dir if topic is a physical directory)
example.com/topic/ to sub.example.com/topic/
example.com/topic/subtopic1/subtopic2/ to sub.example.com/topic/subtopic1/subtopic2/
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
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 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
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
I would like to remove directory from URL. I have a page in mydomain.com/dir/ and all links works under mydomain.com/dir/link1.html, mydomain.com/dir/link2.html etc.
I would like to create single URL which will be mydomain.com/new_link and will trace to mydomain.com/dir/index.php?page=13. I would like it to do only once, for one link, not a regular expression. .htaccess file is located in dir directory with the following content:
RewriteRule ^new_link$ index.php?page=13 [L]
But this causes that the dir is still visible.
I do not entirely understand your question. From what I have understood,
if you want to remove dir from your URL, have your .htaccess in parent directory of dir. I think its the DocumentRoot in your case.
And add this RewriteRule:
RewriteRule ^new_link$ dir/index.php?page=13 [QSA,L]