如何获取我的htaccess文件以允许变量的句点?

时间:2014-05-22 16:02:57

标签: php apache .htaccess mod-rewrite

当我去whats-next/wn_controller.php?user=john.smith时,它有效。但是当我去whats-next/john.smith时,它不起作用。

我试过这一行:

RewriteRule ^whats-next/([A-Za-z0-9-_]+)$ whats-next/wn_controller.php?user=$1 [NC,L] # Process profiles

到此:

RewriteRule ^whats-next/([A-Za-z0-9-\._]+)$ whats-next/wn_controller.php?user=$1 [NC,L] # Process profiles

和此:

RewriteRule ^whats-next/([A-Za-z0-9-._]+)$ whats-next/wn_controller.php?user=$1 [NC,L] # Process profiles

但它还没有解决它。

下面列出了我的完整.htacess文件。

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)$

#RLA Page
RewriteRule ^about/$ whats-next/wn_controller.php [NC,L] # Process about
RewriteRule ^about$ whats-next/wn_controller.php [NC,L] # Process about ##WITHOUT TRAILING DASH URL TOO. FIX SOMEDAY

#What's Next User
RewriteRule ^whats-next/community/$ whats-next/wn_controller.php [NC,L] # Process community
RewriteRule ^whats-next/follow-up/$ whats-next/wn_controller.php [NC,L] # Process follow-up
RewriteRule ^whats-next/people/$ whats-next/wn_controller.php [NC,L] # Process people
RewriteRule ^whats-next/messages/$ whats-next/wn_controller.php [NC,L] # Process messages
RewriteRule ^whats-next/messages([A-Za-z0-9-]+)$ whats-next/wn_controller.php?message=$1 [NC,L] # Process messages
RewriteRule ^whats-next/([A-Za-z0-9-_]+)$ whats-next/wn_controller.php?user=$1 [NC,L] # Process profiles
RewriteRule ^whats-next/settings/$ whats-next/wn_controller.php?user=$1 [NC,L] # Process settings

#What's Next Admin
RewriteRule ^whats-next/admin/$ whats-next/wn_controller.php [NC,L] # Process profiles
RewriteRule ^whats-next/admin$ whats-next/wn_controller.php [NC,L] # Process profiles ##WITHOUT DASH TOO. FIX SOMEDAY

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

1 个答案:

答案 0 :(得分:0)

尝试在0-9之后立即删除短划线。

这对我有用:^whats-next/([A-Za-z0-9._]+)$

enter image description here