Please help me with a redirect issue.
I am trying to redirect from http://www.project/index.php/blog to http://www.project/blog.
I tried the following but it did not work
RewriteRule ^(blog)$ ./index.php/ [L]
Give this a try:
Options +FollowSymlinks
RewriteEngine on
Rewriterule ^index.php/blog(.*)$ http://www.project/blog$1 [r=301,nc]
If you want to append the requested path info at index.php, you might use this RewriteRule
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteRule ^ /index.php%{REQUEST_URI} [L]
Related
I need the url
from
localhost/project/category?c=electronics
to
localhost/project/category/electronics
I have tried
RewriteRule ^category/([^/\.]+)?$ /category.php?c=$1 [L]
RewriteRule ^category/+?$ /category.php?c=$1 [NC,L]
With your shown samples and attempts please try following htaccess rules. Please do clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteBase /
##External redirect to url change in browser.
RewriteCond %{THE_REQUEST} \s/(project/category)\.php\?c=(\S+)\s [NC]
RewriteRule ^ /%1/%2? [R=301,L]
##Internal rewrite to category.php in backend.
RewriteCond %{DOCUMENT_ROOT}/$1/$2.php -f
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ %{DOCUMENT_ROOT}/$1/$2.php?c=$3 [QSA,L]
RewriteEngine on
RewriteBase /
RewriteRule ^project/category/([0-9a-z]+)$ /project/category?c=$1 [L]
Why is "project/" missing in your original try ?
You have to specify the full path.
You can try this simple rewriteRule wich should works.
This is right links:
http://digitalpoint.com.bannedadsense.com
http://businessinsider.com.bannedadsense.com
http://caradvice.com.au.bannedadsense.com
http://bannedadsense.com/index.php
And here is wrong link:
http://bannedadsense.com/
http://bannedadsense.com
This is htaccess code:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^/?(.*).html$ index.php?domainname=$1 [L]
you can see the title of this post, it is problem. or when you go to bannedadsense.com you will see it redirect to new bad url, it should be still in homepage, now it wrong. If you go to bannedadsense.com/index.php then no problem. I need to fix this problem.
Please help me fix the problem in htaccess.
Add that in your .htaccess:
RewriteRule ^/?$ /index.php [R=301,L]
try this,
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_URI} ^$
RewriteRule ^$ http://%{HTTP_HOST}%1 [R]
I want to redirect
http://example.com/report?domain=dollarshaveclub.com
to
http://www.semrush.com/info/dollarshaveclub.com+%28by+organic%29
I've tried:
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^?domain=$
RewriteRule ^report$ http://www.semrush.com/info/$1+%28by+organic%29 [R=301,L]
But I'm not getting anywhere...What could I try next?
You must remove the R=301, part.
This works for me:
RewriteEngine On
RewriteRule ^report$ http://www.semrush.com/info/$1+%28by+organic%29 [NC]
Found the solution finally:
RewriteCond %{QUERY_STRING} ^domain=(.*)
RewriteRule ^report(.*) http://www.semrush.com/info/%1+(by+organic)? [R=301,L]
I have several urls on a Joomla site which have been indexed and I need to 301 redirect them into some new pages. The old URL is formed like this:
http://www.mydomain.com/en/wfmenuconfig/family/family-disease/177-category-english?start=20
I want it to go to:
http://www.mydomain.com/en/family-members/family-disease
I tried using:
RewriteCond %{QUERY_STRING} ^start=(.*)$
RewriteRule ^/en/wfmenuconfig/family/family-disease/177-category-english$ http://www.www.mydoamin.com/en/family-members/family-disease%1 [R=301,L]
I've tried several answers on here but nothing seems to be working.
htaccess 301 redirect dynamic url
and
301 Redirecting URLs based on GET variables in .htaccess
Any ideas what I should try next? (I've tried a normal redirect 301)
You've almost got it. You need to remove the leading slash from your rule's pattern because it's removed from the URI when applying rules from an htaccess file:
RewriteCond %{QUERY_STRING} ^start=(.*)$
RewriteRule ^en/wfmenuconfig/family/family-disease/177-category-english$ /en/family-members/family-disease%1? [R=301,L]
You also don't need the http://www.www.mydoamin.com bit (2 sets of www). At the end of your target, you have family-disease%1, which means if start=20 then the end of your URL will look like: family-disease20. Is that right?
The new URL doesn't have the query string in it, so it is just stripping of the last URL path part. If you want it hardcoded
RewriteCond %{QUERY_STRING} ^start=
RewriteRule ^en/wfmenuconfig/family/family-disease/177-category-english$ /en/family-members/family-disease? [R,L]
or a little bit more flexible
RewriteCond %{QUERY_STRING} ^start=
RewriteRule ^en/wfmenuconfig/family/family-disease/.+$ /en/family-members/family-disease? [R,L]
or if you just want to keep two levels after en/wfmenuconfig
RewriteCond %{QUERY_STRING} ^start=
RewriteRule ^en/wfmenuconfig/(.+?/.+?)/ /en/$1? [R,L]
Never test with 301 enabled, see this answer Tips for debugging .htaccess rewrite rules for details.
If you just want to redirect http://www.mydomain.com/en/wfmenuconfig/family/family-disease/177-category-english?start=$var into http://www.mydomain.com/en/family-members/family-disease, then you must try these directives:
# once per .htaccess file
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{QUERY_STRING} start=([0-9]*)
RewriteRule ^en/wfmenuconfig/family/family-disease/177-category-english /en/family-members/family-disease [R=301,L]
But if that's not what you want, but to redirect http://www.mydomain.com/en/wfmenuconfig/family/family-disease/177-category-english?start=$var into http://www.mydomain.com/en/family-members/family-disease$var then you could check this one:
# once per .htaccess file
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{QUERY_STRING} start=([0-9]*)
RewriteRule ^en/wfmenuconfig/family/family-disease/177-category-english /en/family-members/family-disease%1 [R=301,L]
Now, give this one a little more try if it will work. If it's not, then find any suspicious why this code is not working:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /en/
RewriteCond %{QUERY_STRING} start=([0-9]*)
RewriteRule ^wfmenuconfig/family/family-disease/177-category-english /family-members/family-disease [R]
And go to http://www.mydomain.com/en/wfmenuconfig/family/family-disease/177-category-english?start=$AnyNumber if it's redirecting into http://www.mydomain.com/en/family-members/family-disease just make sure that your web server have mod_rewrite.
I just wanted to throw this out there, I was also having trouble getting the RewriteRule to work. I have a client that upgraded to a WordPress powered site from .asp pages. What I had to do to get this to work is insert the RewriteCond and RewriteRule in the htaccess file BEFORE the "# BEGIN WordPress" section. Now it works just as it should.
This is posted way late, but hopefully it helps someone else out there running into the same issue.
Doesn't Work:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{QUERY_STRING} ^var=somestring$ [NC]
RewriteRule ^oldpage\.asp$ http://www.domain.com/newpage? [R=301,L]
Does Work:
RewriteCond %{QUERY_STRING} ^var=somestring$ [NC]
RewriteRule ^oldpage\.asp$ http://www.domain.com/newpage? [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Order of operations must be important =)
Is it possible to redirect based on an url that would be as:
www.url.com/stuff.php
But not redirect if the url contained any characters after the php, as such:
www.url.com/stuff.php?variables=values&othervariable=othervalue&etc=more
I have no clue how to wriite this either.
Thanks in advance!
Edit: basically I need the redirect to happen to www.url2.com only if www.url.com ends with .php, but not if the .php is followed by variables.
try
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/site.com/?$ /site.com/cart.php [R=301,NC,L]
Try:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/?cart.php$ / [L,R=301]
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^stuff.php$ RELATIVE_OR_ABSOLUTE_URL_HERE [L]