简体   繁体   中英

Codeigniter: Redirect predefined urls to default controller's method

There are two predefined URLs which I want to redirect to default controller's method and return default responses. URLs are:

URL 1: http://EnrollmentService.mydomain.com/EnrollmentServer/Discover.svc (GET request)

URL 2: https://EnrollmentService.mydomain.com/EnrollmentServer/Discover.svc (POST request)

I tried adding following to .htaccess file but no luck.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /testsaav/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    Redirect /enrollmentserver/Discover.svc http://localhost/projectname/
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

Right now I am trying to redirect http://localhost/projectname/EnrollmentServer/Discover.svc to default controller's index method.
I have created a project with default controller name enrollmentserver.php but when I tried to access http://localhost/projectname/enrollmentserver , I got Object not found error

How would redirect both the urls to default controller's any method?

You should use the default CI routes system. In your application/config/routes file:

$route['EnrollmentServer/Discover.svc'] = "projectname";

Or generically:

$route['EnrollmentServer/:any'] = "projectname";

Assuming "projectname" is the controller you want to route to

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM