简体   繁体   中英

How can I get my htaccess file to allow periods for a variable?

When I go to whats-next/wn_controller.php?user=john.smith , it works. But when I go to whats-next/john.smith , it doesn't work.

I've tried to this line:

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

to this:

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

and this:

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

But it hasn't fixed it.

Here is my full .htacess file is listed below.

# 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

Try to remove your dash right after 0-9 .

This worked for me: ^whats-next/([A-Za-z0-9._]+)$

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM