Eclipse webserver path mapping issue with PHP proj

2020-04-21 07:51发布

问题:

I've been reading through the other posts on this topic tried what was suggested in the post and still having the same issue.

I can run my php in an external browser but not in the eclipse browser.

The workspace in the htdoc directory.

I have gone through the debugger and Run Configurations as well. I'm running xampp along with eclipse.

So in eclipse I have a php file to run I select run as webpage:

This is what happens.

Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again

If you think this is a server error, please contact the webmaster. 

Error 404
localhost
7/14/2011 3:49:58 AM
Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4    Perl/v5.10.1 

I know what the problem is it's the path name: when the path is http://localhost/PHP2011X/FreelanceProjects/CLKeenan/CLKeenanfrm.php I get the 404 but when I take out PHP2011X it works fine.

http://localhost/FreelanceProjects/CLKeenan/CLKeenanfrm.php

As a side note the PHP2011X is the project name in eclipse.

I haven't been able to figure out how to change the local url. Thanks in advance for any help.

<Directory "C:/xampp/htdocs">

     Possible values for the Options directive are "None", "All",
     or any combination of:
       Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews

     Note that "MultiViews" must be named *explicitly* --- "Options All"
     doesn't give it to you.

     The Options directive is both complicated and important.  Please see
     http://httpd.apache.org/docs/2.2/mod/core.htmloptions
     for more information.

    Options Indexes FollowSymLinks Includes ExecCGI


     AllowOverride controls what directives may be placed in .htaccess files.
     It can be "All", "None", or any combination of the keywords:
       Options FileInfo AuthConfig Limit

    AllowOverride All


     Controls who can get stuff from this server.

    Order allow,deny
    Allow from all

</Directory>


 DirectoryIndex: sets the file that Apache will serve if a directory
 is requested.

<IfModule dir_module>
    DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
                   default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
                   home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>


 The following lines prevent .htaccess and .htpasswd files from being 
 viewed by Web clients. 

<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>


 ErrorLog: The location of the error log file.
 If you do not specify an ErrorLog directive within a <VirtualHost>
 container, error messages relating to that virtual host will be
 logged here.  If you *do* define an error logfile for a <VirtualHost>
 container, that host's errors will be logged there and not here.

ErrorLog "logs/error.log"

ScriptLog "logs/cgi.log"


 LogLevel: Control the number of messages logged to the error_log.
 Possible values include: debug, info, notice, warn, error, crit,
 alert, emerg.

LogLevel warn

<IfModule log_config_module>

     The following directives define some format nicknames for use with
     a CustomLog directive (see below).

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
       You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>


     The location and format of the access logfile (Common Logfile Format).
     If you do not define any access logfiles within a <VirtualHost>
     container, they will be logged here.  Contrariwise, if you *do*
     define per-<VirtualHost> access logfiles, transactions will be
     logged therein and *not* in this file.

    CustomLog "logs/access.log" common


     If you prefer a logfile with access, agent, and referer information
     (Combined Logfile Format) you can use the following directive.

    CustomLog "logs/access.log" combined
</IfModule>

<IfModule alias_module>

     Redirect: Allows you to tell clients about documents that used to 
     exist in your server's namespace, but do not anymore. The client 
     will make a new request for the document at its new location.
     Example:
     Redirect permanent /foo http://localhost/bar


     Alias: Maps web paths into filesystem paths and is used to
     access content that does not live under the DocumentRoot.
     Example:
     Alias /webpath /full/filesystem/path

     If you include a trailing / on /webpath then the server will
     require it to be present in the URL.  You will also likely
     need to provide a <Directory> section to allow access to
     the filesystem path.


     ScriptAlias: This controls which directories contain server scripts. 
     ScriptAliases are essentially the same as Aliases, except that
     documents in the target directory are treated as applications and
     run by the server when requested rather than as documents sent to the
     client.  The same rules about trailing "/" apply to ScriptAlias
     directives as to Alias.

    ScriptAlias /cgi-bin/ "C:/xampp/cgi-bin/"

</IfModule>

<IfModule cgid_module>

     ScriptSock: On threaded servers, designate the path to the UNIX
     socket used to communicate with the CGI daemon of mod_cgid.

    Scriptsock "logs/cgi.sock"
</IfModule>


 "C:/xampp/cgi-bin" should be changed to whatever your ScriptAliased
 CGI directory exists, if you have that configured.

<Directory "C:/xampp/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>


 DefaultType: the default MIME type the server will use for a document
 if it cannot otherwise determine one, such as from filename extensions.
 If your server contains mostly text or HTML documents, "text/plain" is
 a good value.  If most of your content is binary, such as applications
 or images, you may want to use "application/octet-stream" instead to
 keep browsers from trying to display binary files as though they are
 text.

DefaultType text/plain

<IfModule mime_module>

     TypesConfig points to the file containing the list of mappings from
     filename extension to MIME-type.

    TypesConfig "conf/mime.types"


     AddType allows you to add to or override the MIME configuration
     file specified in TypesConfig for specific file types.

    AddType application/x-gzip .tgz

     AddEncoding allows you to have certain browsers uncompress
     information on the fly. Note: Not all browsers support this.

    AddEncoding x-compress .Z
    AddEncoding x-gzip .gz .tgz

     If the AddEncoding directives above are commented-out, then you
     probably should define those extensions to indicate media types:

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

回答1:

Add PHP2011X as an alias on your webserver, so the address generated by Eclipse does work.

Another solution, but I think Eclipse is really inflexible here, is to define a mapping from the project file paths to project URL paths. But from what I know that is really inflexible and it didn't work most time for me.

So I would go with configuring the webserver instead. If you're using apache, the directive is called Alias.

Edit: You can try to place an Alias directive before the <Directory "C:/xampp/htdocs"> line:

# Map Eclipse Project Name onto webroot (SO #6690405):
Alias /PHP2011X "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">

Related: Setting up path mapping in PHP and Eclipse