dping1968 2014-04-14 05:46
浏览 85
已采纳

更改网址不包括/index.php

I have a simple profile system in place that has a URL re-write that changes URLs like:

www.domain.com/profile.php?id=user 

To:

www.domain.com/user

Using:

RewriteEngine on
RewriteRule ^([A-Za-z0-9]+)$ profile.php?id=$1 [L]

That being said, how would I change the URL:

www.domain.com/something/index.php

To:

www.domain.com/something

Without disrupting the profile URL setup? Would I just put the rewrite higher up in the .htaccess file? Thank you for helping a rookie out.

  • 写回答

2条回答 默认 最新

  • dsstjqsr631426 2014-04-14 06:13
    关注

    If something is not constant it is not possible to do that, you need to use another url pattern like www.domain.com/page/something. However, if the `something constant, you can use;

    RewriteEngine on
    RewriteCond !^something [NC]
    RewriteRule ^([A-Za-z0-9]+)$ profile.php?id=$1 [L]
    
    RewriteCond ^something [NC]
    RewriteRule ^something something/index.php [L] 
    

    If you use different url pattern like ;

    www.domain.com/page/something you can use;

    RewriteEngine on
    RewriteRule ^page/([A-Za-z0-9]+)$ $1/index.php [L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探