Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
598 views
in Technique[技术] by (71.8m points)

.htaccess php Rewrite view.php?visopslag=(id)

I have to rewrite www.url.com/opslag/view.php?visopslag=(id) with htaccess to something more beautiful :o) Im creating a forum likely application. This is what i want to be rewrote: My request is:

www.url.com/opslag/vis/id 

How can I do this? I've tried lots of different things like:

RewriteRule ^/opslag/([^/.]+)/?$ view.php?vis=$1 [L]

My complete .htaccess:

RewriteEngine On  
"#Rewrite view.php?vis=id  
RewriteRule ^opslag/vis/([0-9]+)$ /opslag/view.php?vis=$1 [L,R,QSA]  

"#Remove index.php  
"#RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /.*index.php HTTP/    
"#RewriteRule ^(.*)index.php$ /$1 [R=301,L]  

"#Remove /page/      
"#RewriteCond %{REQUEST_FILENAME} !-f    
"#RewriteCond %{REQUEST_FILENAME} !-d    
"#RewriteRule ^([^/.]+)/?$ index.php?page=$1 [L]
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Please make a backup of your .htaccess file. Now remove all lines -- make it empty (there is too much noise there at the moment).

Add these lines to your empty .htaccess (should be in the root folder of your website):

RewriteEngine On
RewriteRule ^opslag/vis/(d+)$ /opslag/view.php?vis=$1 [NC,QSA,L] 

This should treat www.url.com/opslag/vis/11 as www.url.com/opslag/view.php?vis=11.

Please ensure that you have no more .htaccess files in opslag folder.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...