The relevant parts of the htaccess file are:
Options +SymLinksIfOwnerMatch -MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?services/([^\.]+)/?$ http://www.domain.com/somefolder/web_services/instructions.php?service=$1 [L,QSA]
Visiting a relevant page directly also causes a URL redirect. Ive tried removing all the other rules to check for a double redirect and that did not change anything.
Anybody know what would cause EVERY rewrite to be a 302 redirect?
You need to remove http:// from target URI to avoid full redirect:
Options +SymLinksIfOwnerMatch -MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?services/([^.]+)/?$ somefolder/web_services/instructions.php?service=$1 [L,QSA,NC]
Related
Updating a site and have a ton of redirects.
The issue is that the new URL retains part of the old for all, as seen in the following example:
Redirect 301 /old/oldfile.html /new
redirects to:
http://url.com/new/oldfile.html
Aside from the redirects the htaccess contains the following:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
Options +FollowSymLinks
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Use mod_rewrite instead. This should go above the other rewrite rules.
RewriteEngine on
RewriteRule ^old/oldfile.html /new [R=301,L]
I wrote this code into my .htaccess file, but it seems not to work.
RewriteEngine on
Options +FollowSymLinks
RewriteRule ^([^/]*)\.html$ /category/test.php?name=$1 [L]
When writing http://example.com/z.html it automatically redirects me to 404 file.
Do you have any suggestions?
Make sure you have mod_rewrite enabled and try your rules this way.
Options -MultiViews +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.html$ /category/test.php?name=$1 [L]
This url
example.com/ad/load.php?id=pay.jpg
would become
example.com/ad/pay.jpg
I tried to do this.. but it doesn't work.
Here is my htaccess (into ad folder)
Options +FollowSymLinks
RewriteEngine On
RewriteBase /ad/
RewriteRule ^(\w+) ./load.php?id=$1
Edit
on this root example.com/ad/ I want to show index.php but it does not show. how to fix it
You regex should allow dot also. Try this in /ad/.htaccess:
DirectoryIndex index.php
Options +FollowSymLinks
RewriteEngine On
RewriteBase /ad/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([\w.-]+)/?$ load.php?id=$1 [L,QSA]
I have a site that redirects from www.page.com/timmy to www.page.com/
I would like to redirect www.page.com/timmy to www.page.com/#timmy
How would I do this?
I would like to redirect www.page.com/timmy to www.page.com/#timmy
You may try this in one .htaccess file at root directory:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^timmy /#timmy [L,NC,NE]
For permanent redirection, replace [L,NC,NE] with [R=301,L,NC,NE]
I have an already ok htaccess script that is designed to forward /about to /about.php without displaying it, but I was wondering if anyone knew how to modify my .htaccess file to to forward requests to /about.html to /about (using 302 rather than a hidden redirect)
CheckSpelling on
Options -Indexes
Options +FollowSymlinks
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ /index.php?page=$1 [L,QSA]
try
RewriteCond %{REQUEST_URI} ^/(.+)\.html$ [NC]
RewriteRule . /%1 [R=302,L]