I want to convert this url  http://ts.thebenamorgroup.com/g2g/category.php?cate=mens   to:  http://ts.thebenamorgroup.com/g2g/category/cate/mens/      I have this rule but it doesnt work:  Options +FollowSymLinks RewriteEngine on RewriteRule category/cate/(.*)/ category.php?cate=$1 RewriteRule category/cate/(.*) category.php?cate=$1
487
This is a  about Apache's mod_rewrite.   Changing a request URL or redirecting users to a different URL than the one they originally requested is done using mod_rewrite. This includes such things as:   Changing HTTP to HTTPS (or the other way around) Changing a request to a page which no longer exist to a new replacement. Modifying a URL format (such as ?id=3433 to /id/3433 ) Presenting a different page based on the browser, based on the referrer, based on anything possible under the moon and sun. Anything you want to mess around with URL   Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask!  How can I become an expert at writing mod_rewrite rules?   What is the fundamental format and structure of mod_rewrite rules? What form/flavor of regular expressions do I need to have a solid grasp of? What are the most common mistakes/pitfalls when writing rewrite rules? What is a good method for testing and verifying mod_rewrite rules? Are there SEO or performance implications of mod_rewrite rules I should be aware of? Are there common situations where mod_rewrite might seem like the right tool for the job but isn't? What are some common examples?   A place to test your rules  The  web site is a great place to play around with your rules and test them. It even shows the debug output so you can see what matched and what did not.
52497
I want to let my users submit links to my website something like reddit and digg. I added a meta_key 'syndication_permalink' which contains link to this post. How  could I change the post permalink to link this custom link not to my page?
50110
So, this is the URL:  http://code.google.com/p/es-lab/wiki/Talks#Changes_to_ECMAScript,_Part_2:_Harmony_Highlights_-_proxies_and   When I insert the URL like so:  [Title](URL)   the last part of the URL changes from  Highlights_-_proxies_and   to   Highlights/i-_proxies_and   What's going on here?  Note: See my comment below for a live demonstration of the issue! Feel free to copy the URL and try it for yourself... (It seems that the URL is only altered if the []() notation appears within a comment, but not when it appears within a question/answer.)
82481
Can I use:  &lt;link rel="alternate" hreflang="en" href="?l=en" /&gt;   to link pages with different languages for SEO (recommended for )? Can that URL be relative as in the example above, or does it have to be full (start with http://example.com)?
21711
After having read various articles on this site about WWW or Non-WWW website setup, ,  and , and after having setup a correct redirection rule in .Htaccess to at least eliminate duplicate contents (currently the non-www solution (e.g. http://example.com) I have a feeling that my site rank less since I changed this.   My confusion was strengthened by these two opponents:     &amp;     Could the change of www.example.com >> http://example.com have a factual impact on ranking?  say either is better or worse. Are they holding information back?  I am confused fellow folks...  As much as I would like to separate facts from fiction, I am aware that not all the good valid information is written. Not on google webmaster site and perhaps not elsewhere. If so it seems out of date!  Does or does not a WWW domain impact SEO/rank better than its NON-WWW version? (Given that you have setup a proper redirect to avoid duplicates and go with one)
120114
when typing "a" into my search field (/?s=a) I my search.php template is loaded and all results that match that letter are shown.  If I add this to my .htacess …  RewriteCond %{REQUEST_URI} ^/$ RewriteCond %{QUERY_STRING} ^s=(.+)$ RewriteRule .* /searchmyblog/%1/? [R,L]   and then type "a" into my search the first result of my search is shown. So there is no search.php template shown with all the results but rather the page is redirected to "mypage.com/somecategory/amore-mio"  Why is that happening? I simply want to rewrite the normal /?s= to /search/ or any other custom url.  Any ideas on that? I found heaps of posts online, but none of them seem to be state of the art or use some weird JS-hacks that I find unnecessary.  Ideas on that?
110634
I'm trying to move an existing Bedrock based multisite instance to nginx and am having difficulty getting a set of nginx rules to mimic the original .htaccess. Bedrock places the crux of the files in a wp/ subdirectory, but the urls still need to be accessible from the root domain.  The .htaccess is here as follows:  RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L]  # add a trailing slash to /wp-admin RewriteRule ^wp-admin$ wp-admin/ [R=301,L]  RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L] RewriteRule ^(.*\.php)$ wp/$1 [L] RewriteRule . index.php [L]   I need these at least as nginx conf rules or preferably nginx vhost rules.
108510
I have an URL structure like the following:     sitename.com/cellphone/nokia/galaxy-5678-nokia-cellphone-from-abc/   For more example:     sitename.com/cellphone/motorolla/new-motorolla-gta800-cellphone-from-zxy/   The directory structure is like the cellphone is the main directory of the module and the words like Motorolla and Nokia are subdirectories which are categories and then comes the title of the cellphone.  Here the word cellphone and Nokia in the first link and cellphone and Motorolla in the second link are repeated.  Is it any kind of keyword stuffing? will it be penalized by Google?
30732
What is the difference between these two URLs:   http://example.com/ http://example.com   Should we always add the final / or avoid it? Does it make a difference?
11642
Someone just edited a link in one of my answers to point to a 'better reference'.    I've no problem with links being changed in general, but this smells like part of a concerted attempt to redirect traffic.   Is this kind of activity acceptable on SO?
92637
The Community bot already ran through posts to convert internal http:// links to https://, which is great, but it needs to be run one more time: this time, it needs to convert links of this format:  https://meta.example.stackexchange.com/   to this format:  https://example.meta.stackexchange.com/   Our old meta pages on RPG Stack Exchange contain lots of internal meta references which still follow the old (first) domain protocol.  This link points to rpg.meta and is fine:   However this link points to meta.rpg and contains a privacy error in Chrome because meta.rpg.stackexchange.com doesn't actually have a certificate:         As you can see this means people trying to visit meta links posted before a few months ago are left with no obvious option of how to actually reach the intended destination. They'd also be confused why an obviously Stack Exchange URL is breaking.  Please run that Community edit script another time!  Reported locally on our RPG.SE meta as well here:
88128
Playing with , I'm stuck on a little problem : when I use params with slashes, it confuses the router engine. So is there a nice way to handle this kind of param without having to encode it ?  The code looks like   get 'add/:url' do    #.... end   And I intend to get something like /add/ working
69138
The situation  Across the entire domain, we'd like the URLs to hide file extensions and remove trailing slashes, independent of the domain name itself (as in, works on any domain).  Sample of our directory structure  We're not using index.* files except for the homepage.   /  /index.php /account.php /account  /subscriptions.php  /login.php /login  /reset-password.php     The goal  Some examples of how these files might be requested, and how they should look in the browser:   / and index.php --> mydomain.com (literally just the bare domain name). /account.php or /account/ or /account --> mydomain.com/account /account/subscriptions.php or /account/subscriptions/ or /account/subscriptions --> mydomain.com/account/subscriptions   As you can see, there are several ways to access each webpage, but no matter which of the 2 or 3 ways you use to get there, it only shows the one preferred URL in the browser.  The question  How is this done with .htaccess using mod_rewrite?  I've banged my head against the wall trying to figure this out, but in general, the rewrite flow would seem to be something like this:   External 301 redirect ( mydomain.com/account/ --> mydomain.com/account ) Internally append .php ( mydomain.com/account --> mydomain.com/account.php )   I've been Googling this all day, read thousands of lines of documentation and config texts, and have tried several dozen times... I think more brains on this would help a lot.  UPDATE  We found an answer our question (see below).
118457
I have a substantial number of rewrite rules in place for a variety of reasons such as:  disallow indexes, set custom error pages, force non-www, https, strip trailing slash, redirect index.html or.php to root, pretty URLs (hides file extensions &amp; queries), 404 any URL with Additional Path Info   I was having trouble with nonsense URLs (URLs with Additional Path Info) invoking broken pages &amp; 500 errors that were being indexed as duplicates by search engines.  Sample: example.com/index.php/somefolder/another/file/query...   I set up rules to redirect to a default page rather than rendering broken pages or 500 errors. I then modified that same block to send such nonsense URLs to 404 instead so they would not be indexed.  MrWhite educated me on the proper use of AcceptPathInfo Off but unfortunately this had no effect.  The current solution (full array shown below) requires additional .htaccess files inside any sub-directories containing accessible pages but it worked like a charm.   This is the full array of rules currently in place. Everything is now working perfectly. I'm currently working to eliminate the need for the additional htaccess files in the subdirectories.  AcceptPathInfo Off     Options -Indexes  Options +FollowSymLinks RewriteEngine On RewriteBase /  ## 404 ANY URL WITH ADDITIONAL PATH INFO ## RewriteCond %{THE_REQUEST} /([^.]+)\.php/? [NC]  RewriteRule ^ /%1 [NC,R=404,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/?$ /$1.php [L,NC]  ## SET CUSTOM ERROR PAGES ## ErrorDocument 400 /error/error_400.php ErrorDocument 401 /error/error_401.php ErrorDocument 403 /error/error_403.php ErrorDocument 404 /error/error_404.php ErrorDocument 500 /error/error_500.php  ## FORCE HTTPS &amp; NON-WWW ## ## RewriteEngine On  RewriteCond %{SERVER_PORT} 80  RewriteRule ^(.*)$ https://dev.example.com/$1 [R=301,L,NE]  ## STRIP TRAILING SLASH ## RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [R=301,L]  ## REDIRECT INDEX TO ROOT ## RewriteRule ^index\.php$ / [R=301,L] RewriteRule ^index\.htm$ / [R=301,L]  ## PRETTY URLS FOR DYNAMIC FILES ## RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^items/([a-zA-Z0-9_-]+)$ item.php?item=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^items/([a-zA-Z0-9_-]+)/$ item.php?item=$1 [L]  ## PRETTY URL FOR ANY STATIC FILE ## RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([a-zA-Z0-9_-]+)$ $1.php [L,QSA]   The block labeled "404 ANY URL WITH ADDITIONAL PATH INFO" would be unnecessary if the "AdditionalPathInfo off" directive would work. This setting can also be controlled in the httpd-conf file on the server. Editing httpd-conf requires command-line, ssh access and can be dangerous. Consult your hosting company or server admin if that sounds scary.   Currently using feedback I've received here to clean this up. Updates to come.
91905
I made a site some time ago and after some days some posts were indexed by search engines. Today I changed the permalink structure from /%postname%/ to  /%category%/%postname%/.  After that, when people come to my site from search engines a 404 page not found error appears. I want to change all old URLs to the new category base URL without any 404 error.  How can I do it? By the way, I use Yoast plugin.
16372
This question is here so we can offer users who are looking for information on how to make one or more common or basic redirects in Apache using the htaccess file. All future questions pertaining to finding information that is that is covered by the question should be closed as a duplication of this question. .  Whats the point in this question? The idea while not perfect is catch the most commonly asked questions regarding redirects using the  htaccess on the Apache platform either on  some type of lamp or a live server. The type of answers should be generally those that you could imagine are used by 100,000’s of sites world-wide and are constantly asked here at Pro Webmasters repeatedly over and over in various forms.  A few examples of the type of answers we are looking for:   How can I redirect non-www to www? How can I redirect a sub domain to the main domain? How can I redirect a sub folder from domain to a root or a subdomain?  How can I redirect an old URL to a new URL?   A few examples of the types of answers that we are not looking for:   Answers that do not involve a redirect. Any answers relating to NGinx, IIS or any other non-Apache platform. Answers that involve custom and complex string or query removals.   Resources for Advanced to Complex Mod_Rewrite Rules:      Please note: that this question is still in construction and may need some refining either by myself or a real moderator of Pro Webmasters, if you have any concerns or questions .
120992
I am using following htaccess code to stop hot linking my image files  Options +FollowSymlinks Options +SymlinksIfOwnerMatch  RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://(.+\.)?article-stack.com/ [NC] RewriteCond %{HTTP_REFERER} !^$ ReWriteRule .*.(png|gif|jpg)$ - [N,F,L]   Still the imge of my site are accessible from other sites. how can i stop it?