I have link www.mydomain.com/page.php?pageid=10
I want to change into www.mydomain.com/10
please help me this guys.
Put this in a .htaccess file, and place it in the webroot.
RewriteEngine On
RewriteRule ^([0-9]+)$ page.php?pageid=10
Related
I'm trying to figure out how to redirect all image urls like this:
https://example.com/images/FILE.PNG
to this:
https://example.com/old-site/images/FILE.PNG
Is there an easy way to do this with .htaccess? I've looked around, but couldn't find a post anywhere with a similar scenario of adding a sub directory and don't understand htaccess rules well enough to write it myself.
Any and All help is appreciated!
Using URL Rewrite in .htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/?images/(.*)$ /old-site/images/$1 [R=301,L]
You can use this one-liner rule in your root .htaccess:
RedirectMatch 301 ^(/images/.+)$ /old-site/$1
Can anyone help in learning how to redirect domian.com to www.domain.com (I use Magento) step by step?
Preferably give some screenshots how to do all that.
Also, please let me know how to redirect permanently the category to product page in Magento.
I tried many times doing it on my own seeing some instructions in Google, but really did not help. So, I would like somebody specifically helping me in that.
Hello add below code into your .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com$1 [R=301,L]
</IfModule>
Hope this help you
I have a page as follows.
www.mysite.com/about.php
I want this to be set in the htaccess file so that it looks like below.
www.mysite.com/my-keyword-here
Please help me.
Thanks in advance.
Sam
Add this to the htaccess file in your document root:
RewriteEngine On
RewriteRule ^/?my-keyword-here$ /about.php [L]
So now if you enter http://www.mysite.com/my-keyword-here in your browser's URL address bar, you will be returned the content of /about.php.
I need to do a mass 301 Redirect for all pages ending with .html for my site. I am looking to move all the old .html files to a sub-folder ir.
RedirectMatch 301 (.*)\.html$ http://www.domain.com/folder/$1.html
When I add this and refresh the browser I get a ton of folder/folder/folder now after the url ie
domain.com/folder//folder/folder/folder.....
Any ideas what could be wrong?
Thanks if you can help
The problem is, that 'folder/foo.html' also matches the condition of the RedirectMatch and folder is appended again (and again, and again ...)
Therefore you probably need something like this (untested):
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/folder/
RewriteRule (.*)\.html$ /folder/$1.html [R=301,L]
The RewriteCond should check that the URI doesn't start with /folder and only if this condition is met, the RewriteRule will be checked.
Unfortunately I haven't any Apache installation available at the moment for testing such things, so you will probably have to try it on your own. But I hope you got the idea.
If your old html files are in the root, I would suggest the following:
RedirectMatch 301 ^([^/]+)\.html$ http://www.domain.com/folder/$1.html
In order to convert dynamic URLs on my site www.kitesmovie.co.in to static urls. Eg: www.kitesmovie.co.in/stories.php?id=10 to www.kitesmovie.co.in/Barbara_Mori_Hrithik_Roshan_New_Movie.
I tried using rewriting rules in my htaccess files, but it did not work. Please tell me how to do this.
Thanks a lot in advance.
It's not really clear what you are trying to achieve.
When you say "convert dynamic urls to static urls", do you really want to have user to type in the ...?id=10 and the file named Barbara_Mori_Hrithik_Roshan_New_Movie lives on your server? I think, it's the opposite way - you want to let the user type in the long & nice title and actually resolve it to ?id=10
If this is the case, the #Mike's answer is nearly correct, you only have to swap the parts of the last line:
RewriteRule Barbara_Mori_Hrithik_Roshan_New_Movie stories.php?id=10 [R,L]
Another question - are you sure you have the .htaccess working? An easy way to check is to set the contents of .htaccess to
order deny, allow
deny from all
And see if you can still access that directory. If you can, this means the "deny from all" does not work. Then check your apache config - is .htaccess allowed in the particular virtualhost and/or directory.
Lots of missing info there. If you are using apache with mod_rewite installed, place this in your .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule stories.php?id=10 Barbara_Mori_Hrithik_Roshan_New_Movie [R,L]
</IfModule>
You might want to have a look at this article: http://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/
Generally, you would use a RewriteRule something like this:
RewriteRule ^stories.php?id=10$ Barbara_Mori_Hrithik_Roshan_New_Movie [R=301,L]
If that's not working for you, then feel free to add more details to your question.