Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-16-2012, 01:53 PM   PM User | #1
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,544
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
Problems with my mod rewrite

Hi,

I am trying to make my user to redirect when they go to a certain directory.

Eg when the url is :
http://simpg.net/info/learnturkish
or
http://www.simpg.net/info/learnturkish

The redirection should go to :
http://simpg.net/info.php?a=learnturkish

If have tried the following.
Code:
RewriteCond %{HTTP_HOST} simpg.net [NC]
RewriteCond %{REQUEST_URI} ^/info/ [NC]
RewriteRule ^(.*)$ http://simpg.net/info.php?a=%1 [NC,QSA,L]
But it is not working.

It seems that the "learnturkish" is not getting passed.

What have I done wrong ?

Thanks.
__________________
If you want to attract and keep more clients, then offer great customer support.

Support-Focus.com. automates the process and gives you a trust seal to place on your website.
I recommend that you at least take the 30 day free trial.
jeddi is offline   Reply With Quote
Old 11-16-2012, 05:04 PM   PM User | #2
Arcticwarrio
Regular Coder

 
Arcticwarrio's Avatar
 
Join Date: May 2012
Location: UK
Posts: 624
Thanks: 16
Thanked 70 Times in 70 Posts
Arcticwarrio is on a distinguished road
this is the rule i have:

Code:
Options +FollowSymLinks
RewriteEngine on

RewriteRule index(.*)\.htm$ index.php
RewriteRule (.*)_Home\.htm$ index.php
__________________
There are 10 types of people on CodingForums,
Those who understand Binary and those who dont.
Arcticwarrio is offline   Reply With Quote
Old 12-11-2012, 07:53 PM   PM User | #3
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,544
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
Hi,

I have tried another 2 options

but I can not seem to get this working


I would like :

1.mbpg.net

and


mbpg.net/coupons/1

to get redirected to :

http://mbpg.net/coupon.php?a=1

So I have tried these.

Code:
RewriteCond %{HTTP_HOST} ^([^.]+).mbpg.net [NC]
RewriteCond %{HTTP_HOST} !=www.mbpg.net [NC]
RewriteRule ^.*$ http://mbpg.net/coupon.php?a=%1 [NC,QSA,L]

RewriteCond %{HTTP_HOST} mbpg.net/coupons/^([^.]+) [NC]
RewriteRule ^.*$ http://mbpg.net/coupon.php?a=%1 [NC,QSA,L]
Can anyone help ?

Thanks.


.
__________________
If you want to attract and keep more clients, then offer great customer support.

Support-Focus.com. automates the process and gives you a trust seal to place on your website.
I recommend that you at least take the 30 day free trial.
jeddi is offline   Reply With Quote
Old 12-11-2012, 08:11 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Not sure why this is in the PHP section since it has nothing to do with PHP. Moving to apache configurations.

Can you get any mod_rewrite to work? Use this for your rewrite engine to verify:
Code:
RewriteEngine On
RewriteRule ^/coupons/([^.]+)$ coupon.php?a=$1 [NC,QSA,L]
Fou-Lu is offline   Reply With Quote
Old 12-12-2012, 10:10 AM   PM User | #5
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,544
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
Hi,

Thanks for helping out.

I tried what you suggested.

Here is my .htaccess file:

Code:
Options +FollowSymLinks 
RewriteEngine On

# BELOW IS STUFF TO BLOCK SPAMMING ATTACKS 
######################################################
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|%3D) [OR]

# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]

# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]

# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]

# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})

# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [NC,L]
#
######################################################

RewriteRule ^/coupons/([^.]+)$ coupon.php?a=$1 [NC,QSA,L]
But when I enter this:
http://www.mbpg.net/coupons/1

Quote:
Not Found

The requested URL /coupons/1 was not found on this server.
But when I enter this:
http://www.mbpg.net/coupon.php?a=1

I get my test page come up.

So looks like this redirect isn't working.

Redirects on other sites on this server are working OK

There must be something I have done wrong ??



.
__________________
If you want to attract and keep more clients, then offer great customer support.

Support-Focus.com. automates the process and gives you a trust seal to place on your website.
I recommend that you at least take the 30 day free trial.
jeddi is offline   Reply With Quote
Old 12-12-2012, 02:03 PM   PM User | #6
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
How did I end up with not all chars.
Try with *only* this: RewriteRule coupons/(.+)$ coupon.php?a=$1 [NC,QSA,L] and the rewrite engine enabling. If that still doesn't work with coupons/x, then you cannot use rewrite.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Tags
mod rewrite

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:23 AM.


Advertisement
Log in to turn off these ads.