6 Replies - 2138 Views - Last Post: 15 August 2012 - 08:22 AM

#1 chukwuemmanuel09  Icon User is offline

  • D.I.C Head

Reputation: -10
  • View blog
  • Posts: 60
  • Joined: 18-August 11

mod_rewrite htaccess issue

Posted 15 August 2012 - 06:29 AM

Please i am lost..have been studying Apache mod_rewrite since yesterday...

i have got this
http://www.mysite.co.uk/productDetails.php?id=13 to http://www.mysite.co.uk/productDetails/13



and i want

http://www.mysite.co.uk/productDetails/13



And from all the lectures i have gone through, i believe this should work

RewriteRule ^productDetails/([0-9]+)/?$  productDetails.php?id=$1  [NC,L]  


This post has been edited by chukwuemmanuel09: 15 August 2012 - 06:29 AM


Is This A Good Question/Topic? 0
  • +

Replies To: mod_rewrite htaccess issue

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,991
  • Joined: 08-June 10

Re: mod_rewrite htaccess issue

Posted 15 August 2012 - 07:29 AM

That RewriteRule looks like it should work fine.

What's actually happening? Are you getting an error message?

Is that the only line in your .htaccess file? What else is in there?

Have you turned mod_rewrite on?

P.S.
I've moved this topic over to the Web Servers & Hosting forum. This isn't really a PHP issue.

This post has been edited by Atli: 15 August 2012 - 07:30 AM

Was This Post Helpful? 0
  • +
  • -

#3 chukwuemmanuel09  Icon User is offline

  • D.I.C Head

Reputation: -10
  • View blog
  • Posts: 60
  • Joined: 18-August 11

Re: mod_rewrite htaccess issue

Posted 15 August 2012 - 07:52 AM

Hi, Thanks for your reply...
Yes i have the mod_rewrite on because the second rule works fine...


This is all i have in my .htaccess



Options +FollowSymLinks
RewriteEngine On

RewriteRule ^productDetails/([0-9]+)/?$  productDetails.php?id=$1  [NC,L]

#  Return www.mysite.co.uk 
RewriteCond %{HTTP_HOST} ^mysite.co.uk
RewriteRule (.*) http://www.mysite.co.uk/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.mysite.co.uk [R=301,L]



<FilesMatch "\.(html|css|js|gif|jpg|jpeg|png|ico|swf)$">
    Header set Cache-Control "max-age=600000, proxy-revalidate"
</FilesMatch>

<filesMatch ".(php|cgi)$">
	Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
</filesMatch>


<IfModule mod_headers.c>
  <FilesMatch "\.(js|css|xml|gz)$">
    Header append Vary: Accept-Encoding
	Header append Vary Accept-Encoding
  </FilesMatch>
</IfModule>

# compress the files
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
# removes some bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent




<FilesMatch "\.(htm|html|css|js)$">
AddDefaultCharset UTF-8
</FilesMatch>

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$">
Header unset ETag
FileETag None
</FilesMatch>

# 480 weeks
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
</FilesMatch>

<ifModule mod_gzip.c>
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
  mod_gzip_item_include handler ^cgi-script$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

ExpiresActive on
ExpiresDefault A31536000
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://mysite.co.uk
RewriteCond %{HTTP_REFERER} !^http://www.mysite.co.uk
RewriteRule .*[Jj][Pp][Gg]$|.*[Gg][Ii][Ff]$ http://www.mysite.co.uk/empty.html [L]
#mysite.co.uk/empty.html - your custom hotlinker page






Thanks your viewing..
Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,991
  • Joined: 08-June 10

Re: mod_rewrite htaccess issue

Posted 15 August 2012 - 07:59 AM

View PostAtli, on 15 August 2012 - 02:29 PM, said:

What's actually happening? Are you getting an error message?

Was This Post Helpful? 0
  • +
  • -

#5 chukwuemmanuel09  Icon User is offline

  • D.I.C Head

Reputation: -10
  • View blog
  • Posts: 60
  • Joined: 18-August 11

Re: mod_rewrite htaccess issue

Posted 15 August 2012 - 08:04 AM

Nope..No error...Not just working...

This post has been edited by chukwuemmanuel09: 15 August 2012 - 08:16 AM

Was This Post Helpful? 0
  • +
  • -

#6 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1004
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: mod_rewrite htaccess issue

Posted 15 August 2012 - 08:16 AM

What isn't working?

What do you see when you navigate to http://example.com/productDetails/13? Exactly.
Was This Post Helpful? 0
  • +
  • -

#7 chukwuemmanuel09  Icon User is offline

  • D.I.C Head

Reputation: -10
  • View blog
  • Posts: 60
  • Joined: 18-August 11

Re: mod_rewrite htaccess issue

Posted 15 August 2012 - 08:22 AM

When i navigate to that page what i see is

www.mysite.co.uk/productDetails.php?id=13

instead of

www.mysite.co.uk/productDetails/13
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1