Jump to content

Difficult to rewrite the link. Htaccess in php


diepnghitinh

Recommended Posts

Hello, I was a student studying PHP programming language from Vietnam.

Where I live, I can not find any information referring to what my question. Therefore I was looking to you to ask for help. Because my English is not good what should you expect mercy wrong understanding.  :)

 

I have a path to true as follows:

 

http://localhost/shop/index.php?do=[...] ($_GET[do])

 

http://localhost/shop/index.php?do=[...]&cat=[...] ($_GET[do] and $_GET[cat])

 

PHP code as follows:

 

<?php 
echo 'get show:'.$ _GET [do].' to '.$ _GET [cat]; 
?> 

 

Now I are having a trouble here! Browser I want the form

http://localhost/shop/test

 

Then the browser will show that:

get show: test to

 

and when the browser is as follows:

http://localhost/shop/test/12

This will show the form

get show: test to 12

 

Problems lies in its configuration file:

 

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?do=$1
RewriteRule ^(.*)/([0-9]+)$ index.php?do=$1&cat=$2

 

If I use code RewriteRule ^(.*)$ index.php?=$1 when the Browser form

http://localhost/shop/test/12

show that:

get show: test/12 to

 

Not

(Get show: test to 12) as you want! Who helped with

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.