I have installed SVN and use it to maintain access to my repositories via the http protocol (http://localhost/svn/project_name/ maps to the physical location /var/www/repos).
I also have Apache installed for my web application (with a physical location of /var/www/web_app). This can be access via http://localhost/, rendering a default action (Presenter: Homepage, Action: default - this yields index.php).
However, when I want to view the Contact Page (Presenter: Contact, Action: default - yielding http://localshots/contact) it says:
NOT FOUND The requested URL /contact was not found on this server.
The error doesn't look like it is a framework error (bad code for routing in the framework or something similar). It looks like there is a conflict between in .htaccess or the apache config.
I'm using a PHP framework (called Nette, but I think it's not important what framework is being used: I think the problem lies between the routing and apache configs).
So, it seems that you have no rewrite rule for the url you are requesting.
2 possibility here, you write a new rule like :
RewriteRule ^[/]*contact$ index.php?page=contact [L]
The second is to modify the url you want to reech like http://localhost/contact.php, then create a php file a the root of your project.
EDIT :
You can also do it like this :
RewriteRule ^[/]*contact$ contact.php [L]
So you have a beautiful url and redirect directly to your file
Related
The following code, in index.php, gives the expected routing behaviour when I run it using the built in php web server:
<?php
$request = $_SERVER['REQUEST_URI'];
switch ($request) {
case '/' :
echo 'This is the Home Page';
break;
case '/about' :
echo ' This is the About Page';
break;
default:
echo 'Resource not Found (404)';
break;
}
The same code uploaded to my Ionos Linux web server running Apache does not work: If I access the root directory from a firefox browser (eg http://mywebsites.org.uk/root-directory) I get Resource not Found (404)in the browser. If I append something to the URL (eg http://mywebsites.org.uk/root-directory/about) the browser just gives some page with advertising on which is what you get when there is nothing corresponding to that path on the server). Same happens if you change 'about' for any other word.
I tried with the following .htaccess file in the root directory along with the index.php file:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php [QSA,L]
Now I get the same result with http://mywebsites.org.uk/root-directory. That shows Resource not Found (404) in the browser as before. However, with http://mywebsites.org.uk/root-directory/about or any word substituting 'about' I now get an error message in the browser:
Multiple Choices
The document name you requested (/index.php) could not be found on this server. However, we found documents with names similar to the one you requested.
Available documents:
/index.html (common basename)
When I click on index.html (which is hyperlinked) I find that it is in the directory above the root-directory with the index.php file in it. Ie it is in the mywebsites.org.uk directory. Obviously it is not what I am after.
I also tried replacing the content of the .htaccess file with FallbackResource /index.php. The result was the same as when I had no .htaccess file at all which I described earlier.
I am finding it very difficult to understand my Ionos web server. I do not know if I can change configuration files for Apache or not and I have little understanding of .htaccess files. I have thought of changing to AWS over this issue as the documentation there seems more thorough. However I would prefer not to change if I can sort this issue out. Basically I want to be able to build a PHP router on my Ionos server which runs Apache.,
You are correct that the built-in PHP web server enables you to use a routing script. However, in environments such as your hosting on Ionos, this function is generally performed by whatever web server is running.
Unfortunately, I'm having trouble finding which web server Ionos offers by scanning their web site. Are you certain that they are running Apache and that they have mod_rewrite and local .htaccess overrides enabled? Any of these could explain why you're having issues there.
From your description of your issues, it also sounds like your web site may not have its document root path configured correctly, or that it is not set up to use index.php as a directory index file (e.g. via the DirectoryIndex Apache configuration setting).
The best I can suggest is contacting Ionos techical support or seeking out any technical documentation they offer to customers. I can't even tell if or what configurations they may allow you to override.
i have a site abc.com in php and now made anothers site abcd.com on rails, i wish to redirect all requests that go to the php site to redirect to abcd.com...
example:
abc.com/page3 -> abcd.com/page3
abc.com/non_existing_link ->abcd.com
this php site is just hard coded, not using any framework and i wish to write script in index.php which would accept ny link towards abc.com and then check the extension and redirect it accordingly to the corresponding links on abcd.com... i was suggested to write a controller from a collegue and i am not familiar with mvc functionalities nor th controllers class and stuff...
If your webserver runs apache, I would recommend placing a .htaccess-file in the root of your original server as in the following answer: .htaccess redirect all pages to new domain. If you would like to keep the names the same (redirect to exactly the same name on your new domain), use the following lines:
RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,QSA]
This method works with very limited amount of work/coding :-)
I believe you there are several ways to achieve so:
Using php redirect in all php pages.
How to make a redirect in PHP?
Modifying .htaccess file in your directory
http://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file%3F
If you have a cpanel of other controler system from hosting provider then do it directly there.
I am trying to enable clean urls with Angular JS inside my Laravel 4 app. When I tried the required thing normally without laravel 4 refering to this url.
http://www.yearofmoo.com/2012/11/angularjs-and-seo.html, I was able to get the thing to work. Even ?_escaped_fragment_= was changed to snapshot/* folder and picked the content.
But I am not able to do the same in Laravel 4. I am not sure how to do this.
I am trying to define a route like ?_escaped_fragment_=/* and redirect it to some controller but that doesn't work.
Can anyone please help.
Escaped fragment is a query parameter, not a route, there for, in the root route Route::get('/', 'RootCtrl');, you can check for $_GET['_escaped_fragment'] presence, and if it is there, return an HTTP 302 redirect to the corresponding file in the snapshots dir.
While this will work, it is not the perfect solution, since some bots might index the path of the snapshots file instead of the original one, and since doing it using the Laravel framework is not correct in the first place.
The best choice of course, is to rewrite any request that contains an _escaped_fragment_
query parameter to it's corresponding path, in the nginx\apache configuration, prior to the configuration of your Laravel app, this way those requests won't event reach the Laravel router.
I have co-authored an Angular SEO plug-and-play solution, using PhantomJS & Mongoose integrated web server, to pre-render any Async JS code, and server it as raw HTML.
The server configuration aspects are also explained in the README.md file, please note that if you would like to use static snapshots, just change proxy-pass to rewrite(in order for the right URL to get indexed by the bots).
Hope that helps.
Example using simple rewrites with nginx:
if ($args ~* "^_escaped_fragment_=(.+)") {
set $path $1
set $args '';
rewrite ^.*$ /snapshots/$path last;
}
EDIT:
Apache, for your request (some words of advice: move to nginx).
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^_escaped_fragment=(.+)$
RewriteRule ^.*$ /snapshots/%1 [QSA,L]
</IfModule>
My Project is done in Symfony 1.4 framework (PHP). Its configured on my machine and I can access the application as http://localhost:8082.
All my urls are like
xhttpx://localhost:8082/login
xhttpx://localhost:8082/logout
xhttpx://localhost:8082/new/item
xhttpx://localhost:8082/item/edit/id/34 etc.
Now i want to change all my urls to
xhttpx://localhost:8082/pink/login
xhttpx://localhost:8082/pink/logout
xhttpx://localhost:8082/pink/new/item
xhttpx://localhost:8082/pink/item/edit/id/34 etc.
i.e. append pink after the base url (http://localhost:8087).
I want to achieve this without modifying the Symfony 1.4 files (e.g. routing.yml etc).
I guess we can achieve this by modifying the httpd.conf and by writing appropriate rewrite rule.
Note: please read xhttpx as http, as stackoverflow was not allowing me to post hyperlinks.
Please help.
Create a .htaccess file in the root, containing this:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://localhost:8082/pink/$1 [R=301,L]
This tells Apache to route all traffic in the folder that the .htaccess is in to /pink/.
My backend URLs look like this:
mysite.com/backend.php/blog
I'd like to change it to:
mysite.com/backend/blog
Technically this isn't limited to admin apps, as Symfony grants every application two front controller scripts. But I hate having the script name in URLs and as such I'd like to change it. Is this possible?
Thanks in advance.
Edit
#codecowboy - I did resolve this by creating a 'backend' directory in the web directory. I then copied over the .htaccess file symfony puts in web, and I moved the backend.php and backend_dev.php front controllers to /backend and renamed them index.php and index_dev.php. Then within each front controller I tell PHP to look one directory further up for the project config class. I've been doing this for a while now and it serves my needs perfectly. I actually wrapped this all up in a task so that setting up a new admin app is a 1 step processs.
You can add
#I'm no regular expression expert or mod_rewrite expert, this line probably has some bugs
RewriteRule ^backend(.*)$ backend.php [QSA,L]
to your .htaccess file right before
RewriteRule ^(.*)$ index.php [QSA,L]
and that solves 1/2 of your problem. Anything sent to yoursite.com/backend/xxx will be routed through backend.php. The other problem you get is with internal symfony routing. It will interpret yoursite.com/backend/xxx as a request for module "backend" and action "xxx". I'm sure it's not too hard to solve. Good Luck!