变量.htaccess后的字符串

变量.htaccess后的字符串,.htaccess,webserver,.htaccess,Webserver,我遇到了一个小问题: 我想做一个简短的链接,让用户查看user test.test的图像 我的代码: RewriteRule ^(.*)\.(.*)$/images images.php?user-id=$1.$2 [QSA,L] 例如: website.com/tester.tester/images您过早地用$关闭了表达式,这将导致错误 这应该适合您: RewriteRule ^(.*)\.(.*)/images$ images.php?user-id=$1.$2 [QSA,L] 您的文

我遇到了一个小问题:

我想做一个简短的链接,让用户查看user test.test的图像

我的代码:

RewriteRule ^(.*)\.(.*)$/images images.php?user-id=$1.$2 [QSA,L]
例如:


website.com/tester.tester/images您过早地用$关闭了表达式,这将导致错误

这应该适合您:

RewriteRule ^(.*)\.(.*)/images$ images.php?user-id=$1.$2 [QSA,L]
您的文件现在应该如下所示:

RewriteEngine on

RewriteRule ^(login|settings|friends|gallery|logout|signup|administrator)/?$ $1.php [NC,L]
RewriteRule ^home/?$ profile.php?user-id=home [QSA,NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^index [NC]
RewriteRule ^(.*)\.(.*)\/images$ images.php?user-id=$1.$2 [QSA,L]
RewriteRule ^(.*)\.(.*)$ profile.php?user-id=$1.$2 [QSA,L]

# RewriteRule ^([A-Za-z0-9-\s]+)\.([A-Za-z0-9-\s]+)$ profile.php?user-id=$1.$2 [QSA,L] #Umlaute müssen gehen!!

我尽了最大努力,希望它能奏效。但我对此并不满意:

更新代码:

RewriteEngine On    # Turn on the rewriting engine

RewriteRule ^(login|settings|friends|gallery|logout|signup|administrator)/?$ $1.php [NC,L]
RewriteRule ^home/?$ profile.php?user-id=home [QSA,NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{THE_REQUEST} ^(.*)\.(.*)\/images [NC]
RewriteRule ^(.*)\.(.*)\/images$ images.php?user-id=$1.$2 [QSA,L]

RewriteCond %{THE_REQUEST} ^(.*)\.(.*)\/images\/ [NC]
RewriteRule ^(.*)\.(.*)\/images\/$ images.php?user-id=$1.$2 [QSA,L]

RewriteCond %{THE_REQUEST} !^(.*)\.(.*)\/images\/ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^index [NC]

RewriteCond %{THE_REQUEST} ^(.*)\.(.*) [NC]
RewriteRule ^(.*)\.(.*)$ profile.php?user-id=$1.$2 [QSA,L]

RewriteCond %{THE_REQUEST} ^(.*)\.(.*)\/ [NC]
RewriteRule ^(.*)\.(.*)\/$ profile.php?user-id=$1.$2 [QSA,L]
结果是正确的,但是如果用户在tester.tester/中键入错误的页面,则加载

这让我很恼火。但是我试过了,即使是这个小问题也可以用PHP解决,我真的不知道


谢谢你的回答!!:谢谢,但好像不行。。。我更新了问题,也许这有助于理解。您更新的代码没有任何关于上述规则或您的原始代码的内容……但我认为将代码放置在何处很重要。我试着把它放在重写条件之上,它似乎不起作用,在重写条件之后,它没有意义,后面没有逻辑。我将看看如何使用您的代码,并在这里放置答案。谢谢你的帮助!:d图像之前的/必须为\/反斜杠+斜杠。但是,我也试过了,现在效果更好了。再次感谢您的更新和回复!:D
RewriteEngine On    # Turn on the rewriting engine

RewriteRule ^(login|settings|friends|gallery|logout|signup|administrator)/?$ $1.php [NC,L]
RewriteRule ^home/?$ profile.php?user-id=home [QSA,NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{THE_REQUEST} ^(.*)\.(.*)\/images [NC]
RewriteRule ^(.*)\.(.*)\/images$ images.php?user-id=$1.$2 [QSA,L]

RewriteCond %{THE_REQUEST} ^(.*)\.(.*)\/images\/ [NC]
RewriteRule ^(.*)\.(.*)\/images\/$ images.php?user-id=$1.$2 [QSA,L]

RewriteCond %{THE_REQUEST} !^(.*)\.(.*)\/images\/ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^index [NC]

RewriteCond %{THE_REQUEST} ^(.*)\.(.*) [NC]
RewriteRule ^(.*)\.(.*)$ profile.php?user-id=$1.$2 [QSA,L]

RewriteCond %{THE_REQUEST} ^(.*)\.(.*)\/ [NC]
RewriteRule ^(.*)\.(.*)\/$ profile.php?user-id=$1.$2 [QSA,L]