dougua9165 2016-01-16 08:42
浏览 256
已采纳

如何在Apache中映射此URL?

I've taken over a project where the old developer just disappeared, and my first self-assigned task is to be able to replicate the entire stack on an EC2 host.

On the original pre-existing host, I can hit a URL that is http://www.example.com/users/login/ (I can drop the trailing slash and it hits the login page just fine).

Looking through the source code in /var/www/[example.com]/ -- I can find a sections/users/login.php that looks like it is where the HTML page is rendered from.

I have this same code in my secondary EC2 host, however I'm not bothering to use virtual hosts, I'm just putting it in /var/www/html/ (rather than /var/www/[example.com]/), but I'm getting a 404.

Where should I look for the mapping that points the http://www.example.com/users/login/ to /sections/users/login.php?

I am not that well-acquainted with RewriteRule stuff, but the only 2 .htaccess files in the repo, and in the httpd.conf, I see nothing to do with 'sections' anywhere, so I'm not sure where to look.

The .htaccess in my root directory is:

php_value post_max_size 1024M
php_value upload_max_filesize 1024M
php_value memory_limit 1024M
php_value max_input_time 1800
php_value max_execution_time 1900
php_value session.gc_maxlifetime 7200

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^(.*)example.mobi [NC]
    RewriteRule ^(.*)$ http://%1example.com/$1 [R=301,L]

    RewriteCond %{HTTP_HOST} ^(.*)example.us [NC]
    RewriteRule ^(.*)$ http://%1example.com/$1 [R=301,L]

    RewriteBase /

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]

    RewriteRule ^(.*)\.vcf vcf.php [L]

    RewriteRule ^shared/(.*)$ /$1 [L,NC,R]

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

Options -Indexes
  • 写回答

2条回答 默认 最新

  • doushengyou2617 2016-01-16 09:35
    关注

    In this case, it appears that the RewriteRule is rewriting all the requests to the index.php file. This is very common in frameworks but you can accomplish it without a framework. Inside the index.php file it is parsing the query string and re-mapping it to the appropriate PHP files.

    It should be noted that it will only rewrite to the index.php file if it does not find a matching file or directory in the request - that's what this rule does:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加