I have the following url:
http://www.trashtheweb.com/index.php/home/archive/?p=1
I would like to rewrite this into http://www.trashtheweb.com/archive/?p=1
I tried the following, but this is giving me 404 errors.
RewriteEngine on
RewriteRule ^index.php/home/(.*)$ $1
RewriteEngine on
RewriteBase /
RewriteRule ^index\.php/home/(.*)$ $1 [L,R=301,QSA]
This code do the job (tried on a blank configuration). If not, you probably have some other files interfering.
Related
I am trying to redirect users from /#adam to /user/adam on my Litespeed server which uses .htaccess files.
I have already tried the following :
RewriteEngine On
RewriteBase /
RewriteRule ^\/#.+$ /user/$1
I expected it to redirect, but it does not. Even tried some variations like
RewriteEngine On
RewriteBase /
RewriteRule ^\/#(.+)$ /user/$1
You are close!
Do this:
RewriteBase /
RewriteRule ^#(.+)$ /user/$1
Notice I removed the leading \/
If you need to rigorously test htaccess rules then I highly recommend this gem: https://htaccess.madewithlove.be/
Suddenly GWT has reported over 50 404 errors for urls of this type
http://example.com/abc/&sa=U&ved=0CCYQFjADahUKEwi_lo-6nInHAhXIoZQKHfkXDZw&usg=AFQjCNEfkaKtU35GolQ-KLlTBjIuoMejlQ
I want to redirect these ugly and irrelevant urls to the actual URL i.e http://example.com/abc/
Will this code do the job
RedirectMatch ^/&sa$ /$1? [R=301,L]
or should i use query string for the same??
You can use this rule in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^([^&]+)& /$1? [L,NE,R=302]
I'm attempting to get apache to rewrite a request to mysite.com/blog/<number> to the file /blog.php?page=<number>. However, using a regex which does match that path, the URL is not rewritten and instead a 404 is returned as /blog/ is a nonexistent directory.
Here is the RewriteRule I'm using:
RewriteEngine On
RewriteRule ^blog/[0-9]+/? /blog.php?page=$1 [L]
I haven't used apache in quite a while, so I may have forgotten some extremely simple item which is required, but I cannot see anything wrong with the rule.
Edit:
RewriteRules from httpd.conf:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
You're not grouping the numbers after ^blog/ using round brackets, that's why $1 will be empty.
Try this rule in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^blog/([0-9]+)/?$ /blog.php?page=$1 [L,NC,QSA]
In my website,when it is clicked "www.anketurkiye.com/ekonomianket", I want to my site to redirect to www.anketurkiye.com/ekonomibuton.php page. I have written the following script.However it doesn't run correctly. How can I solve this problem.
RewriteEngine on
RewriteRule ^/ekonomianket$ ekonomibuton.php [NC,L]
Replace that RewriteRule line with this:
RewriteRule ^ekonomianket/?$ ekonomibuton.php [NC,L]
In your .htaccess leading slash is stripped off so you need to match without leading slash.
I have some url's where somehow following keyword appearing
which causes url status to 404. I want to check using .htaccess that if url contains
this form eg. domain/<\?=BASEURL?>/other_part_of_url
then it will be converted to domain/other_part_of_url
I have tried with
RewriteRule /
for testing purpose I have checked for < only but it is not working.
Try this code in your .htaccess:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteOptions MaxRedirects=10
RewriteRule ^[^/]+/(.*)$ /$1 [L,R=301,QSA]
Try:
RewriteRule /<\?=BASEURL\?>/ /