2013-08-11 2 views
2

나는 우호적 인 URL을 만들고 싶습니다.URL과 같은 프로필을 만드는 방법은 무엇입니까?

나는 사용자가 Beraki 내가

RewriteEngine On 
RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?username=$1 
RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?username=$1 

작업 퍼펙트

내가이

그런 짓을 할이 website.com/beraki 같은 일부가

** website.com/beraki/약

website.com/beraki/photos

website.com/beraki/friends**

+0

http://stackoverflow.com/questions/9159949/url- rewrite-mod-rewrite-htaccess-on-apache-and-php – underscore

답변

2
RewriteEngine On 

# Optional '/' sign can be simplified with '?' 
RewriteRule ^([a-z0-9_-]+)/?$ profile.php?username=$1     [NC,L] 

# If you want to specify your list of valid parts after each username: 
RewriteRule ^([a-z0-9_-]+)/(about|photos|friends)$ profile.php?username=$1&page=$2  [NC,L] 

# If you want regex for the part after username: 
RewriteRule ^([a-z0-9_-]+)/(a-z)$ profile.php?username=$1&page=$2 [NC,L] 
1

당신은 you.Simple 쉽게 :

RewriteRule ^([^/]*)/([^/]*)$ /?username=$1&link=$2 [L] 

링크를 도울 수있는이 generator .This 발전기를 시도 할 수 있습니다 페이지의 이름입니다. 예 : about, options etc. 프로필 페이지에 대한 액세스를 원할 경우.

website.com/?username=Beraki & 링크 = 약 -> website.com/Beraki/about

+0

건설적인 대답은 아니며 주석이어야합니다. –

+0

나는 알고 있지만, 나는 말할 수 없다. 내 평판을 보라. – Filip

+3

@DarylGill에는 건설적인 것이 있습니까? – Beraki

관련 문제