durangod

Well-Known Member
May 12, 2012
504
46
78
cPanel Access Level
Website Owner
Hi, i thought i would try to learn how to use redirect in htaccess but its not going well at all.

Here is what i have so far... i know its wrong just not sure where..

The trick is if i can learn to get it to redirect with it on, then i think all i have to do is add the ! symbol
like this to check if its off <IfModule !mod_rewrite.c>
(i think) lol

Code:
# If mod rewrite  enabled then redirect to special page
<IfModule mod_rewrite.c>
Redirect 301 / no_rewrite.shtml [L]
</IfModule>
thanks
 
Last edited by a moderator:

durangod

Well-Known Member
May 12, 2012
504
46
78
cPanel Access Level
Website Owner
I never could get redirect to work, stupid half witted worthless apache instructions lol

But i tested and this works..

Code:
#only check this 1 time
#before all the other rewrites in your htaccess file
#no need to check this on every rewrite code section
#if mod_rewrite is disabled then send them
#to a special error page

<IfModule !mod_rewrite.c>
RewriteRule ^.*$ no_rewrite.shtml [L]
</IfModule>
 

ffeingol

Well-Known Member
PartnerNOC
Nov 9, 2001
629
205
343
cPanel Access Level
DataCenter Provider
The 3rd parameter is a URL and you don't have a URL ( mod_alias - Apache HTTP Server Version 2.4 ) I also dont' beleive you can use the rules (like [L]) since this is just a redirect and not a rewrite rule.

So you'd want something like:

Code:
# If mod rewrite  enabled then redirect to special page
<IfModule mod_rewrite.c>
Redirect 301 / https://www.example.com/no_rewrite.shtml
</IfModule>
 

durangod

Well-Known Member
May 12, 2012
504
46
78
cPanel Access Level
Website Owner
Thanks, i was trying to use a local dir file and in myscript and trying to not hardcode the full url...

Dont forget that i added ! before the mod_ and changed the text comment to if mod rewrite is disabled :)