dtrgqjcd877528 2013-04-15 04:37
浏览 20

检测URL apache中的单斜线

I'm having problem in detecting the single slash only in the URL, the URL which I want is

http://sitename.com/username

through this Rewrite RULE i can capture the username but its also valid for leading slashes as well which is unwanted.

RewriteRule ([A-Za-z0-9]+){0,1}$ index.php?c=profile&val=$1 [NC,L]

^ starting sign returns nothing so I've removed it, Right now I'm testing it over local host so my test url is

http://localhost/projectname/username

on server its

http://sitename.com/username

this is my complete .htaccess

RewriteEngine On
RewriteBase /projectname/

RewriteCond $1 !^(maintainance\.php|index\.php|files|images|robots\.txt|css|js)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [PT,L]

RewriteRule ^([A-Za-z0-9]+){0,1}$ index.php?c=profile&val=$1 [NC,L]

Can anyone please tell me how can I capture the single slash username throught rewriteRule

any help would be greatly appreciated.

Thanks

  • 写回答

1条回答 默认 最新

  • doumie7914 2013-04-15 04:51
    关注

    Please try with the following htaccess script. In val you can get the url values.exploding by / you can get the user name.

    RewriteEngine On
    RewriteBase /projectname/
    RewriteRule ^([A-Za-z0-9]+){0,1}$ index.php?c=profile&val=%{REQUEST_URI} [L,NC,QSA]
    
    评论

报告相同问题?

悬赏问题

  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法