I have written a rule for redirecting in .htaccess file
its redirecting for some pages , if we give that link manually..
but what i want is ,it should redirect automatically....
My requirement is :
Instead of this link,
links.php?page=1&ipp=All&exchange=adddata
It should be redirected automatically
http://example.com/folder1/links/1/All/exchange.html
MY rule in .htaccess is
RewriteEngine On
RewriteRule ^([0-9]+)/All/exchange.html$ links.php?page=1&ipp=All&exchange=adddata
It's not completely clear by your example, but it could be this:
RewriteEngine On
RewriteRule ^links.php?page=([0-9]+)&ipp=All&exchange=adddata$ folder$1/links/$1/All/exchange.html
In the comment above you mistakenly swaped the original url and the url it should be redirected to plus you didn't set any dynamic parameters in your new url - which I suppose you need. But as I said, to be sure about it we'd need more examples.
Hope this helps!
Related
i tryed to search everywhere for this problem but i didnt found nothing.
I want to make make a url seo friendly so i used this code:
RewriteEngine on
RewriteRule ^Homepage index.php [NC,L]
Then i want to redirect to it so i tryed to write this code:
RewriteRule ^index.php$ http://localhost/siti/socialmark/Homepage [R=301,L]
The error it's a loop of redirections, can someone help me?
SORRY FOR MY BAD ENGLISH!
The rewrite rules don't just make the URL string look different, it actually directs the user to the file at the end of the path even if you don't see it in the address bar. If Homepage is a directory containing index.php, even if that php file name doesn't appear in the URL, then it's causing a loop because it's directing you to a directory with an index.php.
The rule is executed every time that page loads. So, you're redirecting to a page which runs the redirect script, so it runs the rule to redirect again, and that causes the loop. What you want to do is create a condition that says "Don't run this code if the requested page is http://localhost/siti/socialmark/Homepage"
Something like this (you may have to adjust it)
RewriteBase /
RewriteCond %{REQUEST_URI} !=/siti/socialmark/Homepage
RewriteRule ^Homepage index.php [NC,L]
For more details, see the caveats and example here:
http://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_l
I just had to make general changes and had to move all url-s from one php page to another. This caused over 64000 missing url from Google. How can i change the old url like:
www.website.com/shop.php?product=nokia-phones-s5
to new url which is
www.website.com/store.php?product=nokia-phones-s5
The only difference is shop.php in url becomes store.php
What is better - php redirect and how or .htaccess redirect and how?
Thank you
You can use this code in your /phones/.htaccess file:
RewriteEngine On
RewriteBase /phones/
RewriteRule ^shop\.php$ store.php [L,NC,NE,R=301]
Query string is automatically forwarded to new target.
i have an url like
http://example.com/folder1/folder2/admin_login.php
the above is active page. but i want to show the below url instead of above but functioning the same page.
http://example.com/folder1/folder2/login
So the question is display url-2 in browser but exeuctes url-1
i have tried this code in htaccess file
RewriteEngine on
RewriteRule ^folder1/folder2/admin_login.php$ http://example.com/folder1/folder2/login [NC,L]
When i put url-1 in browser address bar. it will convert into the url-2 but shows Page Not Found
You have it turned around. You want the second url to be in the address bar. That means you have to link to that url. When a request with that url comes to the server, the server has to internally translate that url to a working url. Besides that, you should not have the full url as a rewrite target, because this causes the rule to function as a redirect instead of an internal rewrite.
The following rule should do the trick:
RewriteRule ^folder1/folder2/login/?$ /folder1/folder2/admin_login.php [L]
I have recently removed a module from Magento that created vanity URL, for filtered searches.
When I've removed this module its now using URL parameters for all filtered navigation pages.
I want to redirect all of these vanity urls to the same page without the vanity part of the URL.
An example of a URL that I want redirecting is:
/hand-dryers/high-speed/shopby/brand-jet_towel-ultradry-magnum_multi_dri-dyson/handdryer_dryingtime_seconds-under_10_seconds/
Redirecting to
/hand-dryers/high-speed
The way the module worked would be by adding the string "shopby" and then converting each parameter into a readable format.
I need a rewrite rule to re-direct all URLs that contain "shopby" to the same URL but with everything from "shopby" removed
I hope this makes sense.
Look forward to hearing back from someone
Should work:
RewriteEngine on
RewriteRule (/.*)/shopby $1 [R=302,L]
After testing you can change the 302 to 301 to ensure the old URLs are pruned from search engine indexes.
Try this:
RewriteRule ^(.+?)/shopby/?.*$ $1/shopby [L]
Consider my domain name is
www.mydomain.com
Consider a page request
www.mydomain.com/user/register
I want to add a custom word after base URL for every request inside mydomain.com.example
www.mydomain.com/customword/
www.mydomain.com/customword/user/register
Can we do this using URL rewriting in htaccess file ?
Actually it should execute 'www.mydomain.com/user/register' internally...but externally the URL should look like www.mydomain.com/customword/user/register.
You could create the directory "register", and put an index file inside it that performs the action.
That's probably the simplest way without url rewriting anyway.
UPDATE (since the question was updated)
In .htaccess:
RewriteEngine On
RewriteRule ^([A-Za-z0-9-.]+)/user/register/?$ user/register.php?customword=$1
register.php will receive a GET request:
//User went to www.mydomain/word/user/register
echo $_GET['customword']; // will return word in this case
Make sure that you have mod_rewrite enabled :)
Yes, you can do it with htaccess
Here is an example which will add a trailing slash with url if it doesnt contain trailing slash
http://enarion.net/web/htaccess/trailing-slash/
edit formatting updated
If you are serving one site from this then the following should work:
Edit your .htaccess file to do a url rewrite
accessing www.yourdomain.com/user/registry will actually server content from www.yourdomain.com/customword/user/registry
RewriteEngine On<br>
RewriteCond %{REQUEST_URI} !^/customword/<br>
RewriteRule ^(.*)$ /customword/$1
You haven't mentioned what kind of site you;re using..eg: PHP, MVC etc as you could do similar thing in there as well.