English 中文(简体)
Mod_Rewrite and web structure
原标题:Mod_Rewrite and website links structure

我有一个网站,内容如此。

指数.php / home.php /profile.php /news.php /phos。 php

newsfeed.php - for news article

照片:php

还有一个用户名称,即用户可以简短地了解其形象。

mysite.com/UserName

现在,在用户名称中使用该代码的Im。

RewriteEngine on
RewriteOptions MaxRedirects=1
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]
RewriteRule ^([^/]+)/?$ profile.php?u=$1 [L]

now I want to rewrite all my links to be SE-Friendly like this

index.php   --> index
home.php    --> home
photos.php  --> photos
videos.php  --> videos

newsfeed.php?id=xx  --> news/xx
photo.php?id=xx     --> photo/xx

那么,什么想法?

最佳回答

这里我做的是:

RewriteEngine on
RewriteOptions MaxRedirects=1
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]
RewriteRule ^users/([^/]+)/?$ profile.php?u=$1 [L]
RewriteRule ^news/([0-9]+)/?$ newsfeed.php?id=$1 [L]
RewriteRule ^photo/([0-9]+)/?$ photo.php?id=$1 [L]
RewriteRule ^videos/?$ videos.php [L]
RewriteRule ^index/?$ index.php [L]
RewriteRule ^home/?$ home.php [L]

只是补充它们。

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签